Package org.apache.tuscany.sca.assembly

Examples of org.apache.tuscany.sca.assembly.Composite


        //System.err.println(bos.toString());
    }

    public void testReadWriteComposite() throws Exception {
        InputStream is = getClass().getResourceAsStream("/Calculator.composite");
        Composite composite = staxProcessor.read(is, Composite.class);
        assertNotNull(composite);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(composite, bos);
        assertEquals("<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><binding.sca /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" target=\"AddServiceComponent\"><binding.sca /></reference><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\"><service><binding.sca /></service></component><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /></composite>",
            bos.toString() );
View Full Code Here


               
                //update runtime with contribution sca definitions
                //this should be done before building the composite
                domainManagementRuntime.updateSCADefinitions(domainManagementContributionService.getContributionSCADefinitions());
               
                Composite composite = null;
               
                for (DeployedArtifact artifact: domainManagementContribution.getArtifacts()) {
                    if (domainCompositeName.equals(artifact.getURI())) {
                        composite = (Composite)artifact.getModel();
                    }
                }
               
                if (composite != null) {
               
                    domainManagementComposite.getIncludes().add(composite);
                    domainManagementRuntime.buildComposite(composite);
                   
                    if (domainModel.getDomainURL() != null) {
                        URI domainURI = URI.create(domainModel.getDomainURI());
                        String domainHost = domainURI.getHost();
                        int domainPort = domainURI.getPort();
                       
                        // override any domain URLs in node.composite and replace with the
                        // domain url provided on start up
                        for ( Component component : composite.getComponents()){
                            for (ComponentReference reference : component.getReferences() ){
                                for (Binding binding : reference.getBindings() ) {
                                    String bindingURIString = binding.getURI();
                                    if (bindingURIString != null) {
                                        URI bindingURI = URI.create(bindingURIString);
View Full Code Here

    }   
   
   
    public String getComposite(QName compositeQName){
       
        Composite composite = null;
        for(Composite tmpComposite : domainManagementComposite.getIncludes()){
            if (tmpComposite.getName().equals(compositeQName)){
                composite = tmpComposite;
            }
        }
View Full Code Here

        try {

           
            if (domainManagementRuntime != null) {
                Composite composite = domainManagementComposite.getIncludes().get(0);
               
                domainManagementRuntime.getCompositeActivator().stop(composite);
                domainManagementRuntime.getCompositeActivator().deactivate(composite);
               
                domainManagementComposite.getIncludes().clear();
View Full Code Here

    public void testReadComposite() throws Exception {
        CompositeProcessor compositeProcessor = new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor);
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = compositeProcessor.read(reader);
        assertNotNull(composite);

        CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, mapper, null, null);
        compositeUtil.build(composite);
View Full Code Here

        SCADefinitions scaDefns = scaDefnDocProcessor.read(null, uri, url);
               
        CompositeProcessor compositeProcessor = new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor);
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = compositeProcessor.read(reader);
        assertNotNull(composite);
       
        staxProcessor.resolve(scaDefns, resolver);
        staxProcessor.resolve(composite, resolver);

        CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, mapper, scaDefns.getPolicySets(), null);
        compositeUtil.build(composite);
       
        //intents are computed and aggregate intents from ancestor elements
        assertEquals(((PolicySetAttachPoint)composite.getComponents().get(0)).getRequiredIntents().size(), 3);
        assertEquals(((PolicySetAttachPoint)composite.getComponents().get(5)).getRequiredIntents().size(), 3);
       
        //assertEquals(((OperationsConfigurator)composite.getComponents().get(0)).getConfiguredOperations().isEmpty(), true);
        //assertEquals(((OperationsConfigurator)composite.getComponents().get(5)).getConfiguredOperations().isEmpty(), false);
       
       
        //test for proper aggregation of policy intents on implementation elements
        for ( Intent intent : ((PolicySetAttachPoint)composite.getComponents().get(0).getImplementation()).getRequiredIntents() ) {
            String intentName = intent.getName().getLocalPart();
            if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_2") ||
                intentName.equals("tuscanyIntent_3")) ) {
                fail();
            }
        }
       
        for ( Intent intent : ((PolicySetAttachPoint)composite.getComponents().get(5)).getRequiredIntents() ) {
            String intentName = intent.getName().getLocalPart();
            if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
                intentName.equals("tuscanyIntent_5")) ) {
                fail();
            }
        }

        //test for proper aggregation of policy intents and policysets on operations of implementation
        OperationsConfigurator opConf = (OperationsConfigurator)composite.getComponents().get(5);
        assertEquals(opConf.getConfiguredOperations().get(0).getRequiredIntents().size(), 4);
        for ( Intent intent :  opConf.getConfiguredOperations().get(0).getRequiredIntents()) {
            String intentName = intent.getName().getLocalPart();
            if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
                intentName.equals("tuscanyIntent_5") || intentName.equals("tuscanyIntent_6") ) ) {
                fail();
            }
        }
       
        opConf = (OperationsConfigurator)composite.getComponents().get(6);
        assertEquals(opConf.getConfiguredOperations().get(0).getRequiredIntents().size(), 3);
        for ( Intent intent :  opConf.getConfiguredOperations().get(0).getRequiredIntents()) {
            String intentName = intent.getName().getLocalPart();
            if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
                intentName.equals("tuscanyIntent_6.qualified2") ) ) {
View Full Code Here

        SCADefinitions scaDefns = scaDefnDocProcessor.read(null, uri, url);
               
        CompositeProcessor compositeProcessor = new CompositeProcessor(new ContributionFactoryImpl(), assemblyFactory, policyFactory, mapper, staxProcessor);
        InputStream is = getClass().getResourceAsStream("Calculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = compositeProcessor.read(reader);
        assertNotNull(composite);
       
        staxProcessor.resolve(scaDefns, resolver);
        staxProcessor.resolve(composite, resolver);

        CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, mapper, scaDefns.getPolicySets(), null);
        compositeUtil.build(composite);
       
        //intents are computed and erased since there will be matching policysets
        assertEquals(((PolicySetAttachPoint)composite.getComponents().get(0)).getRequiredIntents().size(), 0);
        assertEquals(((PolicySetAttachPoint)composite.getComponents().get(5)).getRequiredIntents().size(), 0);
       
        //test for determination of policysets for implementation
        assertEquals(((PolicySetAttachPoint)composite.getComponents().get(0)).getPolicySets().size(), 1);
        for ( PolicySet policySet : ((PolicySetAttachPoint)composite.getComponents().get(0).getImplementation()).getPolicySets() ) {
            String policySetName = policySet.getName().getLocalPart();
            if ( !(policySetName.equals("tuscanyPolicySet_1")) ) {
                fail();
            }
        }
       
        assertEquals(((PolicySetAttachPoint)composite.getComponents().get(5)).getPolicySets().size(), 2);
        for ( PolicySet policySet : ((PolicySetAttachPoint)composite.getComponents().get(5).getImplementation()).getPolicySets() ) {
            String policySetName = policySet.getName().getLocalPart();
            if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")) ) {
                fail();
            }
        }

        //test for computation of policysets on operations of implementation
        OperationsConfigurator opConf = (OperationsConfigurator)composite.getComponents().get(5);
        assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 3);
        for ( PolicySet policySet : opConf.getConfiguredOperations().get(0).getPolicySets() ) {
            String policySetName = policySet.getName().getLocalPart();
            if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")
                    || policySetName.equals("tuscanyPolicySet_3")) ) {
                fail();
            }
        }
       
        opConf = (OperationsConfigurator)composite.getComponents().get(6);
        assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 3);
        for ( PolicySet policySet : opConf.getConfiguredOperations().get(0).getPolicySets() ) {
            String policySetName = policySet.getName().getLocalPart();
            if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")
                    || policySetName.equals("tuscanyPolicySet_4")) ) {
View Full Code Here

        // list of deployables
        String prefix = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
        for (DeployedArtifact artifact : contribution.getArtifacts()) {
            if (artifact.getModel() instanceof Composite) {
                if (artifact.getURI().startsWith(prefix)) {
                    Composite composite = (Composite)artifact.getModel();
                    if (!contribution.getDeployables().contains(composite)) {
                        contribution.getDeployables().add(composite);
                    }
                }
            }
View Full Code Here

        }

        //resolve deployables from contribution metadata
        List<Composite> resolvedDeployables = new ArrayList<Composite>();
        for (Composite deployableComposite : contribution.getDeployables()) {
            Composite resolvedDeployable =
                contribution.getModelResolver().resolveModel(Composite.class, deployableComposite);

            resolvedDeployables.add(resolvedDeployable);
        }
        contribution.getDeployables().clear();
View Full Code Here

     */
    protected String getCompositeURI(Composite c, InstalledContribution ic) {
        for (Artifact a : ic.getContribution().getArtifacts()) {
            if (a.getModel() != null) {
                if (a.getModel() instanceof Composite) {
                    Composite cm = a.getModel();
                    if (c.getName().equals(cm.getName())) {
                        return cm.getURI();
                    }
                }
            }
        }
        // shouldn't ever happen
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.assembly.Composite

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.