Package org.apache.tuscany.sca.implementation.node

Examples of org.apache.tuscany.sca.implementation.node.ConfiguredNodeImplementation


                artifactProcessors.getProcessor(ConfiguredNodeImplementation.class);
            URL configurationURL = new URL(configurationURI);
            InputStream is = configurationURL.openStream();
            XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
            reader.nextTag();
            ConfiguredNodeImplementation configuration = configurationProcessor.read(reader);
            is.close();

            // Resolve contribution URLs
            for (Contribution contribution : configuration.getContributions()) {
                URL contributionURL = new URL(configurationURL, contribution.getLocation());
                contribution.setLocation(contributionURL.toString());
            }

            // Resolve composite URL
            URL compositeURL = new URL(configurationURL, configuration.getComposite().getURI());
            configuration.getComposite().setURI(compositeURL.toString());

            // Configure the node
            configureNode(configuration);

        } catch (Exception e) {
View Full Code Here


        logger.log(Level.INFO, "Creating node: " + configurationName);

        try {
            initRuntime();

            ConfiguredNodeImplementation config = findNodeConfiguration(null, null);
            configureNode(config);
        } catch (ServiceRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

        }
        try {
            // Initialize the runtime
            initRuntime();

            ConfiguredNodeImplementation config = findNodeConfiguration(compositeURI, classLoader);
            configureNode(config);
        } catch (ServiceRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

     */
    private ConfiguredNodeImplementation findNodeConfiguration(final String compositeURI, ClassLoader classLoader)
        throws Exception {
        NodeImplementationFactory nodeImplementationFactory =
            modelFactories.getFactory(NodeImplementationFactory.class);
        ConfiguredNodeImplementation config = nodeImplementationFactory.createConfiguredNodeImplementation();

        // Default to thread context classloader
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        String contributionArtifactPath = compositeURI;
        URL contributionArtifactURL = null;
        if (compositeURI != null) {
            contributionArtifactURL = getResource(classLoader, compositeURI);
            if (contributionArtifactURL == null) {
                throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
            }
            // Set to relative URI to avoid duplicate loading
            Composite composite = createComposite(compositeURI);
            config.setComposite(composite);
        } else {
            // No composite is specified, tring to search the SCA metadata files
            contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META;
            contributionArtifactURL = getResource(classLoader, Contribution.SCA_CONTRIBUTION_META);

            if (contributionArtifactURL == null) {
                contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META;
                contributionArtifactURL = getResource(classLoader, Contribution.SCA_CONTRIBUTION_GENERATED_META);
            }
            if (contributionArtifactURL == null) {
                contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
                contributionArtifactURL = getResource(classLoader, Contribution.SCA_CONTRIBUTION_DEPLOYABLES);
            }
           
            // No contribution can be discovered
            if (contributionArtifactURL == null) {
                throw new IllegalArgumentException("No default contribution can be discovered on the classpath");
            }
           
            // No composite will be created, all deployable composites will be used later
        }

        Contribution c = getContribution(contributionArtifactURL, contributionArtifactPath);
        config.getContributions().add(c);

        return config;
    }
View Full Code Here

        try {
            // Initialize the runtime
            initRuntime();

            URI uri = compositeURI == null ? null : URI.create(compositeURI);
            ConfiguredNodeImplementation configuration = null;
            if (contributions == null || contributions.length == 0) {
                if (uri != null && uri.getScheme() != null) {
                    throw new IllegalArgumentException("No SCA contributions are provided");
                }
                configuration = findNodeConfiguration(compositeURI, null);
            } else {

                // Create a node configuration
                NodeImplementationFactory nodeImplementationFactory =
                    modelFactories.getFactory(NodeImplementationFactory.class);
                configuration = nodeImplementationFactory.createConfiguredNodeImplementation();

                Composite composite = compositeURI == null ? null : createComposite(compositeURI);
                configuration.setComposite(composite);
 

                // Create contribution models
                ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
                for (SCAContribution c : contributions) {
                    Contribution contribution = createContribution(contributionFactory, c);
                    configuration.getContributions().add(contribution);
                }
            }

            // Configure the node
            configureNode(configuration);
View Full Code Here

        try {
            // Initialize the runtime
            initRuntime();

            ConfiguredNodeImplementation configuration = null;
            if (contributions == null || contributions.length == 0) {
                configuration = findNodeConfiguration(compositeURI, null);
            } else {
                // Create a node configuration
                NodeImplementationFactory nodeImplementationFactory =
                    modelFactories.getFactory(NodeImplementationFactory.class);
                configuration = nodeImplementationFactory.createConfiguredNodeImplementation();

                // Read the composite model
                StAXArtifactProcessor<Composite> compositeProcessor = artifactProcessors.getProcessor(Composite.class);
                // URL compositeURL = new URL(compositeURI);
                logger.log(Level.INFO, "Loading composite: " + compositeURI);

                CompositeDocumentProcessor compositeDocProcessor =
                    (CompositeDocumentProcessor)documentProcessors.getProcessor(Composite.class);
                composite =
                    compositeDocProcessor.read(URI.create(compositeURI), new ByteArrayInputStream(compositeContent
                        .getBytes("UTF-8")));

                analyzeProblems();

                configuration.setComposite(composite);

                // Create contribution models
                ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
                for (SCAContribution c : contributions) {
                    Contribution contribution = createContribution(contributionFactory, c);
                    configuration.getContributions().add(contribution);
                }
            }

            // Configure the node
            configureNode(configuration);
View Full Code Here

            // Initialize the runtime
            init();

            // Create a node configuration
            NodeImplementationFactory nodeImplementationFactory = modelFactories.getFactory(NodeImplementationFactory.class);
            ConfiguredNodeImplementation configuration = nodeImplementationFactory.createConfiguredNodeImplementation();

            if (compositeURI != null) {
                Composite composite = assemblyFactory.createComposite();
                composite.setURI(compositeURI);
                composite.setUnresolved(true);
                configuration.setComposite(composite);
            }

                // Create contribution models
            for (org.apache.tuscany.sca.node.Contribution c : contributions) {
                Contribution contribution = contribution(contributionFactory, c);
                configuration.getContributions().add(contribution);
            }

            // Configure the node
            configureNode(configuration);
View Full Code Here

            StAXArtifactProcessor<ConfiguredNodeImplementation> configurationProcessor = xmlProcessors.getProcessor(ConfiguredNodeImplementation.class);
            URL configurationURL = new URL(configurationURI);
            InputStream is = configurationURL.openStream();
            XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
            reader.nextTag();
            ConfiguredNodeImplementation configuration = configurationProcessor.read(reader);
            is.close();

            // Resolve contribution URLs
            for (Contribution contribution : configuration.getContributions()) {
                URL contributionURL = new URL(configurationURL, contribution.getLocation());
                contribution.setLocation(contributionURL.toString());
            }

            // Resolve composite URL
            URL compositeURL = new URL(configurationURL, configuration.getComposite().getURI());
            configuration.getComposite().setURI(compositeURL.toString());

            // Configure the node
            configureNode(configuration);

        } catch (Exception e) {
View Full Code Here

            // Initialize the runtime
            init();

            // Create a node configuration
            NodeImplementationFactory nodeImplementationFactory = modelFactories.getFactory(NodeImplementationFactory.class);
            ConfiguredNodeImplementation configuration = nodeImplementationFactory.createConfiguredNodeImplementation();

            if (compositeURI != null) {
                Composite composite = assemblyFactory.createComposite();
                composite.setURI(compositeURI);
                composite.setUnresolved(true);
                configuration.setComposite(composite);
            }

                // Create contribution models
            for (org.apache.tuscany.sca.node.Contribution c : contributions) {
                Contribution contribution = contribution(contributionFactory, c);
                configuration.getContributions().add(contribution);
            }

            // Configure the node
            configureNode(configuration);
View Full Code Here

            // Initialize the runtime
            init();

            // Create a node configuration
            NodeImplementationFactory nodeImplementationFactory = modelFactories.getFactory(NodeImplementationFactory.class);
            ConfiguredNodeImplementation configuration = nodeImplementationFactory.createConfiguredNodeImplementation();

            // Read the composite model
            logger.log(Level.INFO, "Loading composite: " + compositeURI);

            XMLStreamReader reader = inputFactory.createXMLStreamReader(new ByteArrayInputStream(compositeContent.getBytes("UTF-8")));
            reader.nextTag();

            // Read the composite model
            composite = (Composite)compositeProcessor.read(reader);
            if (composite != null && compositeURI != null) {
                composite.setURI(compositeURI);
            }
            analyzeProblems();

            configuration.setComposite(composite);

            // Create contribution models
            for (org.apache.tuscany.sca.node.Contribution c : contributions) {
                Contribution contribution = contribution(contributionFactory, c);
                configuration.getContributions().add(contribution);
            }

            // Configure the node
            configureNode(configuration);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.node.ConfiguredNodeImplementation

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.