Package org.apache.tuscany.sca.domain

Examples of org.apache.tuscany.sca.domain.DomainException


           
            // remove contribution from the contribution processor
            try {
                domainManagementContributionService.remove(contributionURI);
            } catch (Exception ex){
                throw new DomainException(ex);
            }
           
            // stop and tidy any nodes running this contribution
            for ( NodeModel node : domainModel.getNodes().values()){
                if (node.getContributions().containsKey(contributionURI)) {
                    try {               
                        if (node.getLifecycleState() == LifecyleState.RUNNING) {
                            ((NodeModelImpl)node).getSCANodeManagerService().stop();
                            node.setLifecycleState(LifecyleState.DEPLOYED);
                        }
                       
                        // remove all contributions from this node including the
                        // one that is specifically being removed.
                        for (ContributionModel tmpContributionModel :  node.getContributions().values()){
                            ((NodeModelImpl)node).getSCANodeManagerService().removeContribution(tmpContributionModel.getContributionURI());
                        }
                       
                        node.getContributions().clear();
                        node.getDeployedComposites().clear();
                        node.setLifecycleState(LifecyleState.AVAILABLE);
                        node.getServices().clear();
                    } catch (Exception ex) {
                        // TODO - collate errors and report
                        ex.printStackTrace();
                    }
                }
            }
        } else {
            throw new DomainException("Contribution " + contributionURI + " not found in domain contributions");
        }
    }
View Full Code Here


        }
    }
   
    public void addDeploymentComposite(String contributionURI, String compositeXML) throws DomainException {
        // TODO
        throw new DomainException("Not yet implemented");       
    }
View Full Code Here

        throw new DomainException("Not yet implemented");       
    }
   
    public void updateDeploymentComposite(String contributionURI, String compositeXML) throws DomainException {
        // TODO
        throw new DomainException("Not yet implemented");        
    }
View Full Code Here

    public void addToDomainLevelComposite(QName compositeQName, String nodeURI) throws DomainException {
       
        try {
            // check to see if this composite has already been added
            if (domainModel.getDeployedComposites().containsKey(compositeQName) ){
                throw new DomainException("Composite " + compositeQName.toString() +
                                          " had already been added to the domain level composite");
            }
           
            // find the contribution that has this composite
            ContributionModel contributionModel = findContributionFromComposite(compositeQName);
           
            if (contributionModel == null){
                throw new DomainException("Can't find contribution for composite " + compositeQName.toString());
            }
           
            // find the composite object from the contribution
            CompositeModel compositeModel = contributionModel.getComposites().get(compositeQName);
           
            if (compositeModel == null){
                throw new DomainException("Can't find composite model " + compositeQName.toString() +
                                          " in contribution " + contributionModel.getContributionURI());
           
           
            // build the contribution to create the services and references
            domainModel.getDeployedComposites().put(compositeQName, compositeModel);
            domainManagementRuntime.getCompositeBuilder().build(compositeModel.getComposite());               
            domainModel.getDomainLevelComposite().getIncludes().add(compositeModel.getComposite());
           
            NodeModel node = null;
           
            // find the node for the composite to run on
            if (nodeURI != null) {
                // find the named node
                node = domainModel.getNodes().get(nodeURI);
               
                if (node == null){
                    throw new DomainException("Node " + nodeURI + " not found in domain");
                }
            } else {
                // noddy algorithm to find a free node
                // TODO - do something better
                for(NodeModel tmpNode : domainModel.getNodes().values()) {
                    if (tmpNode.getLifecycleState() == LifecyleState.AVAILABLE){
                        node = tmpNode;
                    }
                }
               
                if (node == null){
                    throw new DomainException("No free node available to run composite "  + compositeQName.toString());
                }               
            }

            // find all the composites that the node must know about
            List<Contribution> dependentContributions = new ArrayList<Contribution>();
            findDependentContributions(contributionModel.getContribution(), dependentContributions);
            
            // assign the set of contributions to the node model
            for (Contribution tmpContribution : dependentContributions){
                node.getContributions().put(tmpContribution.getURI(),
                                            domainModel.getContributions().get(tmpContribution.getURI()));
            }
           
            // assign the composite to the node model
            node.getDeployedComposites().put(compositeQName, compositeModel);
           
            node.setLifecycleState(LifecyleState.DEPLOYED);
   
            // now pass this information over to the real node
      
           
            // add contributions. Use the dependent contribution list here rather than the
            // one built up in the node model to ensure that contributions are added in the correct order
            // I.e. the top most in the dependency tree last.
            for (Contribution tmpContribution : dependentContributions){
                ((NodeModelImpl)node).getSCANodeManagerService().addContribution(tmpContribution.getURI(),
                         domainModel.getContributions().get(tmpContribution.getURI()).getContributionURL());
            }
   
            // deploy composite
            ((NodeModelImpl)node).getSCANodeManagerService().addToDomainLevelComposite(compositeQName.toString());
                       
            // spray all of the service endpoints from this composite out to interested nodes
            notifyDomainChange();
        } catch (DomainException ex) {           
            throw ex; 
        } catch (Exception ex) {
            throw new DomainException(ex);
        }
           
    }   
View Full Code Here

                        ex.printStackTrace();
                    }               
                }
            }
        } else {
            throw new DomainException("Composite " + compositeQName.toString() + " not found in domain contributions");
        }
    }
View Full Code Here

        try {
            // find the composite object from the list of deployed composites
            CompositeModel compositeModel = domainModel.getDeployedComposites().get(compositeQName);
           
            if (compositeModel == null){
                throw new DomainException("Can't start composite " + compositeQName.toString() +
                                          " as it hasn't been added to the domain level composite");
            }
           
            // find the contribution that has this composite
            ContributionModel contributionModel = findContributionFromComposite(compositeQName);
           
            if (contributionModel == null){
                throw new DomainException("Can't find contribution for composite " + compositeQName.toString());
            }
           
            NodeModel node = null;
           
            // find the node that has this composite
            for(NodeModel tmpNode : domainModel.getNodes().values()) {
                if (tmpNode.getDeployedComposites().containsKey(compositeQName)){
                    node = tmpNode;
                    break;
                }
            }
           
            if (node != null){
                if (node.getLifecycleState() == LifecyleState.DEPLOYED){
                 // start the node
                    ((NodeModelImpl)node).getSCANodeManagerService().start();
                    node.setLifecycleState(LifecyleState.RUNNING);
                }
               
            } else {
                // composite not assigned to node for some reason
                throw new DomainException("Composite "  + compositeQName.toString() +
                                          " is not associated with a node and cannot be started");
            }
        } catch (NodeException ex){
            throw new DomainException(ex);
        }
        
    }
View Full Code Here

    public void stopComposite(QName compositeName) throws DomainException {
        // find the composite object from the list of deployed composites
        CompositeModel composite = domainModel.getDeployedComposites().get(compositeName);
       
        if (composite == null){
            throw new DomainException("Can't stop composite " + compositeName.toString() +
                                      " as it hasn't been added to the domain level composite");
        }
               
        // stop all the nodes running this composite
        for(NodeModel node : domainModel.getNodes().values()) {
View Full Code Here

    
    public void addContribution(String contributionURI, String contributionURL) throws DomainException {
        try {
            domain.addContribution(contributionURI, new URL(contributionURL));
        } catch (Exception ex) {
            throw new DomainException (ex);
        }
    }
View Full Code Here

   
    public void updateContribution(String contributionURI, String contributionURL) throws DomainException {
        try {
            domain.updateContribution(contributionURI, new URL(contributionURL));
        } catch (Exception ex) {
            throw new DomainException (ex);
        }
    }
View Full Code Here

            if (domainModel.getDomainURL() == null) {
              logger.log(Level.INFO, "Domain will be started stand-alone as domain URL is not provided");
            }
           
        } catch(Exception ex) {
            throw new DomainException(ex);
        }           
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.domain.DomainException

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.