Package org.apache.tuscany.sca.domain.model

Examples of org.apache.tuscany.sca.domain.model.ContributionModel


            }
        }
    }
   
    private ContributionModel findContributionFromComposite(QName compositeQName){
        ContributionModel returnContributionModel = null;
       
        for(ContributionModel contributionModel : domainModel.getContributions().values()){           
            if (contributionModel.getComposites().containsKey(compositeQName)){
                returnContributionModel = contributionModel;
            }
View Full Code Here


        dependentContributions.add(contribution);
    }
   
    private ContributionModel parseContribution(String contributionURI, String contributionURL) throws DomainException {
        // add the contribution information to the domain model
        ContributionModel contributionModel = domainModelFactory.createContribution();
        contributionModel.setContributionURI(contributionURI);
        contributionModel.setContributionURL(contributionURL);
        domainModel.getContributions().put(contributionURI, contributionModel);
       
        // read the assembly model objects.     
        try {
            // Create a local model from the contribution. Using the contribution
            // processor from the domain management runtime just because we already have it
            Contribution contribution =  domainManagementContributionService.contribute(contributionURI,
                                                                                        new URL(contributionURL),
                                                                                        false);
           
            contributionModel.setContribution(contribution);
           
            // add the composites into the domain model
            for (Artifact artifact : contribution.getArtifacts()) {
                if (artifact.getModel() instanceof Composite) {
                    Composite composite = (Composite)artifact.getModel();
                    CompositeModel compositeModel = domainModelFactory.createComposite();
                    compositeModel.setCompositeQName(composite.getName());
                    compositeModel.setComposite(composite);
                    contributionModel.getComposites().put(compositeModel.getCompositeQName(), compositeModel);     
                }
            }                       
           
            // add the deployable composite info to the domain model
            for (Composite composite : contribution.getDeployables()) {
                CompositeModel compositeModel = contributionModel.getComposites().get(composite.getName());
               
                if (compositeModel != null){
                    contributionModel.getDeployableComposites().put(compositeModel.getCompositeQName(), compositeModel);
                } else {
                    throw new DomainException("Deployable composite name " +
                                              composite.getName() +
                                              " doesn't match a composite in the contribution " +
                                              contributionURI );
View Full Code Here

*/
    }   

    public void registerContribution(String nodeURI, String contributionURI, String contributionURL) throws DomainException{
        try {
            ContributionModel contributionModel = null;
           
            if ( domainModel.getContributions().containsKey(contributionURI) == false ){
                contributionModel = parseContribution(contributionURI, contributionURL);

                // assign the contribution to the referenced node
View Full Code Here

    public void unregisterContribution(String nodeURI, String contributionURI) throws DomainException {
        try {
           
            if ( domainModel.getContributions().containsKey(contributionURI) == true ){
                // get the contribution model
                ContributionModel contributionModel = domainModel.getContributions().get(contributionURI);
               
                // remove deployed composites
                for (QName compositeQName : contributionModel.getDeployedComposites().keySet()){
                    domainModel.getDomainLevelComposite().getIncludes().remove(contributionModel.getDeployedComposites().get(compositeQName));
                    domainModel.getDeployedComposites().remove(compositeQName);
                }
                   
                // remove contribution from the domain
                domainModel.getContributions().remove(contributionURI);

                // remove the contribution from the referenced node
                NodeModel nodeModel = domainModel.getNodes().get(nodeURI);
               
                if ((nodeModel != null)) {
                    nodeModel.getContributions().remove(contributionURI);
                   
                    // remove deployed composites
                    for (QName compositeQName : contributionModel.getDeployedComposites().keySet()){
                        nodeModel.getDeployedComposites().remove(compositeQName);
                    }
                }
            }           
View Full Code Here

    public void removeContribution(String contributionURI) throws DomainException {
        if ( domainModel.getContributions().containsKey(contributionURI) == true ){
           
            // get the contribution model
            ContributionModel contributionModel = domainModel.getContributions().get(contributionURI);
           
            // remove potentially deployed composites
            for (QName compositeQName : contributionModel.getDeployableComposites().keySet()){
                domainModel.getDeployedComposites().remove(compositeQName);
                domainModel.getDomainLevelComposite().getIncludes().remove(contributionModel.getDeployableComposites().get(compositeQName));
            }
           
            // remove contribution from the domain model
            domainModel.getContributions().remove(contributionURI);
           
View Full Code Here

                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()));
View Full Code Here

    public void removeFromDomainLevelComposite(QName compositeQName) throws DomainException {

        domainModel.getDomainLevelComposite().getIncludes().remove(domainModel.getDeployedComposites().get(compositeQName).getComposite());
        domainModel.getDeployedComposites().remove(compositeQName);
       
        ContributionModel contributionModel = findContributionFromComposite(compositeQName);
       
        if (contributionModel != null){
            contributionModel.getDeployedComposites().remove(compositeQName);
           
            for(NodeModel node : domainModel.getNodes().values()) {
                if ( node.getDeployedComposites().containsKey(compositeQName)){
                    try {
                        if (node.getLifecycleState() == LifecyleState.RUNNING) {
View Full Code Here

                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());
            }
           
View Full Code Here

*/
    }   

    public void registerContribution(String nodeURI, String contributionURI, String contributionURL) throws DomainException{
        try {
            ContributionModel contributionModel = null;
           
            if ( domainModel.getContributions().containsKey(contributionURI) == false ){
                contributionModel = parseContribution(contributionURI, contributionURL);

                // assign the contribution to the referenced node
View Full Code Here

    public void unregisterContribution(String nodeURI, String contributionURI) throws DomainException {
        try {
           
            if ( domainModel.getContributions().containsKey(contributionURI) == true ){
                // get the contribution model
                ContributionModel contributionModel = domainModel.getContributions().get(contributionURI);
               
                // remove deployed composites
                for (QName compositeQName : contributionModel.getDeployedComposites().keySet()){
                    domainModel.getDomainLevelComposite().getIncludes().remove(contributionModel.getDeployedComposites().get(compositeQName));
                    domainModel.getDeployedComposites().remove(compositeQName);
                }
                   
                // remove contribution from the domain
                domainModel.getContributions().remove(contributionURI);

                // remove the contribution from the referenced node
                NodeModel nodeModel = domainModel.getNodes().get(nodeURI);
               
                if ((nodeModel != null)) {
                    nodeModel.getContributions().remove(contributionURI);
                   
                    // remove deployed composites
                    for (QName compositeQName : contributionModel.getDeployedComposites().keySet()){
                        nodeModel.getDeployedComposites().remove(compositeQName);
                    }
                }
            }           
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.domain.model.ContributionModel

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.