Examples of NodeException


Examples of org.apache.tuscany.sca.node.NodeException

           
            // add the contribution to the domain.
            scaDomain.registerContribution(nodeURI, contributionURI, contributionURL.toExternalForm());                 
       
        } catch (Exception ex) {
            throw new NodeException(ex);
        }       
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

           
            // remove the contribution from the domain.
            scaDomain.unregisterContribution(nodeURI, contributionURI);                 
           
        } catch (Exception ex) {
            throw new NodeException(ex);
       
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

            // Remove all contributions
            for (String contributionURI : keys){
                removeContribution(contributionURI);
            }
        } catch (Exception ex) {
            throw new NodeException(ex);
        }             
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

    }
   
    public void addToDomainLevelComposite(QName compositeQName) throws NodeException {
       
        if (nodeStarted){
            throw new NodeException("Can't add composite " + compositeQName.toString() + " when the node is running. Call stop() on the node first");
        }
      
        // if no composite name is specified add all deployable composites
        // to the domain
        if (compositeQName == null){
            for (Composite composite : composites.values()) {
                if (!nodeComposite.getIncludes().contains(composite)) {
                    nodeComposite.getIncludes().add(composite);
                   
                    try {
                        // build and activate the model for this composite
                        activateComposite(composite);
                       
                        // register the composite with the domain
                        scaDomain.registerDomainLevelComposite(nodeURI, composite.getName().toString());                 
                   
                    } catch (Exception ex) {
                        throw new NodeException(ex);
                    }  
                   
                }
            }
        } else {         
            Composite composite = composites.get(compositeQName);
           
            if (composite == null) {
                throw new NodeException("Composite " + compositeQName.toString() + " not found" );
            }
                       
            // if the named composite is not already in the list then deploy it
            if (!nodeComposite.getIncludes().contains(composite)) {
                nodeComposite.getIncludes().add(composite);
               
                try {
                    // build and activate the model for this composite
                    activateComposite(composite);
                   
                    // register the composite with the domain
                    scaDomain.registerDomainLevelComposite(nodeURI, composite.getName().toString());                 
               
                } catch (Exception ex) {
                    throw new NodeException(ex);
                }                
            }
        } 
       
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

            Composite composite = compositeFiles.get(compositePath);
           
            if (composite != null){
                addToDomainLevelComposite(composite.getName());
            } else {
                throw new NodeException("Composite " + compositePath + " not found" );
           
        }
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

                    }
                }
            }

        } catch (Exception ex) {
            throw new NodeException(ex);
       
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

                    stopComposite(composite);
                }
            }
                           
        } catch (Exception ex) {
            throw new NodeException(ex);
        }             
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

        // find the composite that will be updated
        Composite composite = composites.get(compositeQName);
       
        if (composite == null) {
            throw new NodeException("trying to update composite " + compositeQName.toString() +
                                    " which can't be found in node " + nodeURI);
        }
       
        // parse the XML into an composite object
        Composite newComposite = null;
       
        ExtensionPointRegistry registry = nodeRuntime.getExtensionPointRegistry();
        StAXArtifactProcessorExtensionPoint staxProcessors =
            registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
       
        StAXArtifactProcessor<Composite> processor = staxProcessors.getProcessor(Composite.class);
             
        try {
            XMLInputFactory inputFactory = XMLInputFactory.newInstance();
            XMLStreamReader reader = inputFactory.createXMLStreamReader(bais);
            newComposite = processor.read(reader);
            reader.close();
        } catch (Exception ex) {
            throw new NodeException(ex);
        }      

       
        // for each component in the composite compare it against the live component
        for (Component newComponent : newComposite.getComponents()){
            for (Component component : composite.getComponents()){        
                if (component.getName().equals(newComponent.getName())){
                    // compare the component references
                    for (Reference newReference : newComponent.getReferences()){
                        for (Reference reference : component.getReferences()) {          
                            if (reference.getName().equals(newReference.getName())) {
                                boolean referenceChanged = false;
                                List<Binding> removeCandidates = new ArrayList<Binding>();
                                List<Binding> addCandidates = new ArrayList<Binding>();
                               
                                removeCandidates.addAll(reference.getBindings());
                               
                                for (Binding newBinding : newReference.getBindings()){
                                    boolean bindingFound = false;
                                    for (Binding binding : reference.getBindings()){
                                        // find the matching target service binding      
                                        if (binding.getName().equals(newBinding.getName())){
                                            if ((binding.getURI() != null) &&
                                                (newBinding.getURI() != null) &&
                                                !binding.getURI().equals(newBinding.getURI())){
                                                binding.setURI(newBinding.getURI());
                                                referenceChanged = true;
                                               
                                                logger.log(Level.INFO, "Updating binding " +
                                                                       component.getName() +
                                                                       " reference " +
                                                                       reference.getName() +
                                                                       " binding " +
                                                                       binding.getClass().getName() +
                                                                       " URI " +
                                                                       binding.getURI());
                                            }
                                            bindingFound = true;
                                            removeCandidates.remove(binding);
                                        }
                                    }
                                   
                                    if (bindingFound == false){
                                        addCandidates.add(newBinding);
                                    }

                                }
                               
                                for (Binding addBinding : addCandidates){
                                    reference.getBindings().add(addBinding);
                                    referenceChanged = true;
                                    logger.log(Level.INFO, "Adding binding " +
                                            component.getName() +
                                            " reference " +
                                            reference.getName() +
                                            " binding " +
                                            addBinding.getClass().getName() +
                                            " URI " +
                                            addBinding.getURI());                                       
                                }
                               
                                // remove all of the old bindings
                                for (Binding removeBinding : removeCandidates){
                                    reference.getBindings().remove(removeBinding);
                                    referenceChanged = true;
                                    logger.log(Level.INFO, "Removing binding " +
                                            component.getName() +
                                            " reference " +
                                            reference.getName() +
                                            " binding " +
                                            removeBinding.getClass().getName() +
                                            " URI " +
                                            removeBinding.getURI());
                                }
                               
                                // if the node is running restart the reference and the component that holds it
                                if (referenceChanged && nodeStarted){
                                    try {
                                        nodeRuntime.getCompositeActivator().stop((RuntimeComponent)component);
                                        nodeRuntime.getCompositeActivator().deactivate((RuntimeComponent)component,
                                                (RuntimeComponentReference)reference);
                                        nodeRuntime.getCompositeActivator().start((RuntimeComponent)component,
                                                (RuntimeComponentReference)reference);
                                        nodeRuntime.getCompositeActivator().start((RuntimeComponent)component);
                                      
                                    } catch (Exception ex) {
                                        throw new NodeException(ex);
                                    }
                                   
                                }                               
                            }
                        }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

   
    public void destroy() throws NodeException {
        try {
            nodeRuntime.stop();
        } catch(Exception ex) {
            throw new NodeException(ex);
        }
    }
View Full Code Here

Examples of org.apache.tuscany.sca.node.NodeException

            // check whether node uri is an absolute url, 
            try {
                URI tmpURI = new URI(nodeURI);
                nodeURL = tmpURI.toURL();
            } catch(Exception ex) {
                throw new NodeException("node uri " +
                                        nodeURI +
                                        " must be a valid url");
            }
           
            // create a node runtime for the domain contributions to run on
            nodeRuntime = new ReallySmallRuntime(nodeClassLoader);
            nodeRuntime.start();
           
            // get the domain builder
            domainBuilder = nodeRuntime.getDomainBuilder();           
           
            // configure the default port and path for this runtime
            int port = URI.create(nodeURI).getPort();
            String path = nodeURL.getPath();
            ServletHostExtensionPoint servletHosts = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ServletHostExtensionPoint.class);
            for (ServletHost servletHost: servletHosts.getServletHosts()) {
                servletHost.setDefaultPort(port);
                if (path != null && path.length() > 0 && !path.equals("/")) {
                    servletHost.setContextPath(path);
                }
            }           
           
            // make the node available to the model
            // this causes the runtime to start registering binding-sca service endpoints
            // with the domain proxy
            // TODO - This code is due to be pulled out and combined with the register and
            //       resolution code that appears in this class
            ModelFactoryExtensionPoint factories = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            nodeFactory = new NodeFactoryImpl(this);
            factories.addFactory(nodeFactory);
           
            // Create an in-memory domain level composite
            AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
            nodeComposite = assemblyFactory.createComposite();
            nodeComposite.setName(new QName(Constants.SCA10_NS, "node"));
            nodeComposite.setURI(nodeURI);
           
            // add the top level composite into the composite activator
            nodeRuntime.getCompositeActivator().setDomainComposite(nodeComposite);            
           
            // create a link to the domain
            scaDomain = new SCADomainProxyImpl(domainURI, nodeClassLoader);
           
            // add the node URI to the domain
            scaDomain.addNode(this)
           
        } catch(NodeException ex) {
            throw ex;
        } catch(Exception ex) {
            throw new NodeException(ex);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.