Package org.apache.tuscany.sca.definitions

Examples of org.apache.tuscany.sca.definitions.Definitions


        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(WS_POLICY1));
       
        artifact = processor.read(reader, new ProcessorContext());
        assertNotNull(artifact);
        Assert.assertTrue(artifact instanceof Definitions);
        Definitions definitions1 = (Definitions) artifact;

        // Read the second definitions string
       
        reader = inputFactory.createXMLStreamReader(new StringReader(WS_POLICY2));

        artifact = processor.read(reader, new ProcessorContext());
        assertNotNull(artifact);
        Assert.assertTrue(artifact instanceof Definitions);
        Definitions definitions2 = (Definitions) artifact; 
       
        // compare the policies using the policy builder
       
        // create dummy endpoints and endpoint references
        AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
View Full Code Here


        ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        DefinitionsFactory definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
        Definitions definitions = definitionsFactory.createDefinitions();
        DefinitionsUtil.aggregate(systemDefinitions, definitions, monitor);
       
        // create an artifact to represent the system defintions and
        // add it to the contribution
        List<Artifact> artifacts = contribution.getArtifacts();
View Full Code Here

        List<Contribution> contributionList = new ArrayList<Contribution>(contributions);
       
        if (systemContribution == null) {
            systemContribution = cloneSystemContribution(monitor);
        }
        Definitions systemDefinitions = systemContribution.getArtifacts().get(0).getModel();
        // Build an aggregated SCA definitions model. Must be done before we try and
        // resolve any contributions or composites as they may depend on the full
        // definitions.xml picture

        // get all definitions.xml artifacts from contributions and aggregate
View Full Code Here

        init();

        if (systemContribution == null) {
            systemContribution = cloneSystemContribution(monitor);
        }
        Definitions systemDefinitions = systemContribution.getArtifacts().get(0).getModel();
        // Build an aggregated SCA definitions model. Must be done before we try and
        // resolve any contributions or composites as they may depend on the full
        // definitions.xml picture

        // get all definitions.xml artifacts from contributions and aggregate
View Full Code Here

        composite = (Composite)documentProcessor.read(null, uri, url, context);
        assertNotNull(composite);

        url = BuildPolicyTestCase.class.getResource("test_definitions.xml");
        uri = URI.create("test_definitions.xml");
        Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
        assertNotNull(definitions);
        policyDefinitions.add(definitions);

        documentProcessor.resolve(definitions, resolver, context);
        documentProcessor.resolve(composite, resolver, context);
View Full Code Here

        props.put(RemoteConstants.REMOTE_CONFIGS_SUPPORTED, new String[] {"org.osgi.sca"});
       
        ExtensionPointRegistry registry = exporter.getExtensionPointRegistry();
        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
        Deployer deployer = utilities.getUtility(Deployer.class);
        Definitions definitions = deployer.getSystemDefinitions();

        String[] intents = new String[definitions.getIntents().size()];
        int i = 0;
        for (Intent intent : definitions.getIntents()) {
            intents[i++] = intent.toString();
        }

        String[] bindingTypes = new String[definitions.getBindingTypes().size()];
        i = 0;
        for (BindingType bindingType : definitions.getBindingTypes()) {
            bindingTypes[i++] = bindingType.getType().toString();
        }
       
        // FIXME: We should ask SCA domain for the supported intents
        props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, intents);
View Full Code Here

        builders = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class);
    }

    @Test
    public void testBuild() throws Exception {
        Definitions definitions = load("test_definitions.xml");
        Composite composite = load("Calculator.composite");
       
        CompositeBuilder uriBuilder = new StructuralURIBuilderImpl(extensionPoints);

        BuilderContext builderContext = new BuilderContext(extensionPoints);
View Full Code Here

        return model;
    }

    @Test
    public void testComplexBuild() throws Exception {
        Definitions definitions = load("definitions.xml");
        Composite composite1 = load("Composite1.composite");
        Composite composite2 = load("Composite2.composite");
        Composite composite3 = load("Composite3.composite");
        Composite composite4 = load("Composite4.composite");
        composite1.getIncludes().clear();
View Full Code Here

            }
        }
    }
   
    protected void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
        Definitions definitions = context.getDefinitions();
        Set<Intent> intents = new HashSet<Intent>();
        if (definitions != null) {
            for (Intent i : subject.getRequiredIntents()) {
                Intent resolved = resolve(definitions, i);
                if (resolved != null) {
                    intents.add(resolved);
                } else {
                    error(context.getMonitor(), "IntentNotFoundAtBuild", subject, i);
                    // Intent cannot be resolved
                }
            }
        }

        // Replace profile intents with their required intents
        while (!intents.isEmpty()) {
            boolean profileIntentsFound = false;
            Set<Intent> copy = new HashSet<Intent>(intents);
            for (Intent i : copy) {
                if (!i.getRequiredIntents().isEmpty()) {
                    intents.remove(i);
                    intents.addAll(i.getRequiredIntents());
                    profileIntentsFound = true;
                }
            }
            if (!profileIntentsFound) {
                // No more profileIntents
                break;
            }
        }
       
        // Replace unqualified intents if there is a qualified intent in the list
        Set<Intent> copy = new HashSet<Intent>(intents);
        for (Intent i : copy) {
            if (i.getQualifiableIntent() != null) {
                intents.remove(i.getQualifiableIntent());
            }

        }


        subject.getRequiredIntents().clear();
        subject.getRequiredIntents().addAll(intents);

        // TUSCANY-3503 - policy sets now only applied through direct
        //                or external attachement
        // resolve policy set names that have been specified for the
        // policy subject against the real policy sets from the
        // definitions files.
        // Some policy plugins, e.g. JSR250, add resolved policy sets
        // on the fly as they read details from annotations. So check
        // that policy sets are unresolved befor blowing them away with
        // a warning
        Set<PolicySet> policySets = new HashSet<PolicySet>();
        if (definitions != null) {
            for (PolicySet policySet : subject.getPolicySets()) {
                if (policySet.isUnresolved()){
                    int index = definitions.getPolicySets().indexOf(policySet);
                    if (index != -1) {
                        policySets.add(definitions.getPolicySets().get(index));
                    } else {
                        // PolicySet cannot be resolved
                        warning(context.getMonitor(), "PolicySetNotFoundAtBuild", subject, policySet);
                    }
                } else {
View Full Code Here

    // Build the whole composite
    public Composite build(Composite composite, BuilderContext context)
        throws CompositeBuilderException {
        try {

      Definitions definitions = context.getDefinitions();
            if (definitions == null || (definitions.getPolicySets().isEmpty() && definitions.getExternalAttachments().isEmpty()) ) {
                return composite;
            }
            // create a DOM for the Domain Composite Infoset
            Document document = saveAsDOM(composite);
           
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.definitions.Definitions

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.