Package org.apache.tuscany.sca.contribution

Examples of org.apache.tuscany.sca.contribution.Artifact


        Model y = resolver.resolveModel(Model.class, x);
        assertTrue(x == y);
    }
       
    public void testResolvedArtifact() {
        Artifact artifact = factory.createArtifact();
        artifact.setURI("foo/bar");
        resolver.addModel(artifact);
        Artifact x = factory.createArtifact();
        x.setURI("foo/bar");
        x = resolver.resolveModel(Artifact.class, x);
        assertTrue(x == artifact);
    }
View Full Code Here


        Model y = resolver.resolveModel(Model.class, x);
        assertTrue(x == y);
    }
   
    public void testResolvedArtifact() {
        Artifact artifact = factory.createArtifact();
        artifact.setURI("foo/bar");
        resolver.addModel(artifact);
        Artifact x = factory.createArtifact();
        x.setURI("foo/bar");
        x = resolver.resolveModel(Artifact.class, x);
        assertTrue(x == artifact);
    }
View Full Code Here

    }

    public void resolve(WidgetImplementation implementation, ModelResolver resolver) throws ContributionResolveException {
       
        // Resolve the resource directory location
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI(implementation.getLocation());
        Artifact resolved = resolver.resolveModel(Artifact.class, artifact);
        if (resolved.getLocation() != null) {
            try {
                implementation.setLocationURL(new URL(resolved.getLocation()));
                implementation.setUnresolved(false);
               
                //introspect implementation
                WidgetImplementationIntrospector widgetIntrospector = new WidgetImplementationIntrospector(assemblyFactory, implementation);
                widgetIntrospector.introspectImplementation();
View Full Code Here

    }

    public <T> T resolveModel(Class<T> modelClass, T unresolved) {
       
        // Filter based on the artifact URI
        Artifact artifact = (Artifact)unresolved;
        if (export.getURI().equals(artifact.getURI())) {
           
            // The artifact URI matches the exported URI, delegate to the
            // contribution's resolver
            return resolver.resolveModel(modelClass, unresolved);
        } else {
View Full Code Here

    public ArtifactModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
      this.contribution = contribution;
    }

    public void addModel(Object resolved) {
      Artifact artifact = (Artifact)resolved;
        map.put(artifact.getURI(), artifact);
    }
View Full Code Here

        if (uri == null) {
          return (T)unresolved;
        }
       
        // Lookup the artifact
        Artifact resolved = (Artifact) map.get(uri);
        if (resolved != null) {
            return modelClass.cast(resolved);
        }
       
        // If not found, delegate the resolution to the imports (in this case based on the resource imports)
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof ResourceImport) {
              ResourceImport resourceImport = (ResourceImport)import_;
              //check the import location against the computed package name from the componentType URI
                if ((resourceImport.getURI().equals(uri)) &&
                    (resourceImport.getModelResolver() != null)){
                    // Delegate the resolution to the import resolver
                    resolved = resourceImport.getModelResolver().resolveModel(Artifact.class, (Artifact)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
        }
View Full Code Here

     
      if (implementation == null)
        return;
     
        // Resolve the resource directory location
        Artifact artifact = contributionFactory.createArtifact();
        artifact.setURI(implementation.getLocation());
        Artifact resolved = resolver.resolveModel(Artifact.class, artifact);
        if (resolved.getLocation() != null) {
            try {
                implementation.setLocationURL(new URL(resolved.getLocation()));
                implementation.setUnresolved(false);
            } catch (IOException e) {
              ContributionResolveException ce = new ContributionResolveException(e);
              error("ContributionResolveException", resolver, ce);
                //throw ce;
View Full Code Here

    public void resolve(WidgetImplementation implementation, ModelResolver resolver) throws ContributionResolveException {

      if (implementation != null) {
        // Resolve the resource directory location
            Artifact artifact = contributionFactory.createArtifact();
            artifact.setURI(implementation.getLocation());
            Artifact resolved = resolver.resolveModel(Artifact.class, artifact);
            if (resolved.getLocation() != null) {
                try {
                    implementation.setLocationURL(new URL(resolved.getLocation()));

                    //introspect implementation
                    WidgetImplementationIntrospector widgetIntrospector =
                      new WidgetImplementationIntrospector(assemblyFactory, implementation);
                    widgetIntrospector.introspectImplementation();
View Full Code Here

    /**
     * Add a composite model to the contribution
     */
    public void addDeploymentComposite(Contribution contribution, Composite composite) throws ContributionException {
        Artifact artifact = this.contributionFactory.createArtifact();
        artifact.setURI(composite.getURI());
        artifact.setModel(composite);

        contribution.getArtifacts().add(artifact);

        contribution.getDeployables().add(composite);
    }
View Full Code Here

                compositeUris.add(anArtifactUri);
            } else {
                URL artifactURL = packageProcessor.getArtifactURL(new URL(contribution.getLocation()), anArtifactUri);

                // Add the deployed artifact model to the resolver
                Artifact artifact = this.contributionFactory.createArtifact();
                artifact.setURI(anArtifactUri.toString());
                artifact.setLocation(artifactURL.toString());
                contribution.getArtifacts().add(artifact);
                modelResolver.addModel(artifact);

                model = this.artifactProcessor.read(contributionURL, anArtifactUri, artifactURL);

                if (model != null) {
                    artifact.setModel(model);

                    // Add the loaded model to the model resolver
                    modelResolver.addModel(model);

                    // Add policy definitions to the list of policy definitions
                    if (model instanceof SCADefinitions) {
                        policyDefinitions.add(model);

                        SCADefinitions definitions = (SCADefinitions)model;
                        for (Intent intent : definitions.getPolicyIntents() ) {
                            policyDefinitionsResolver.addModel(intent);
                        }

                        for (PolicySet policySet : definitions.getPolicySets() ) {
                            policyDefinitionsResolver.addModel(policySet);
                        }

                        for (IntentAttachPointType attachPointType : definitions.getBindingTypes() ) {
                            policyDefinitionsResolver.addModel(attachPointType);
                        }

                        for (IntentAttachPointType attachPointType : definitions.getImplementationTypes() ) {
                            policyDefinitionsResolver.addModel(attachPointType);
                        }
                        for (Object binding : definitions.getBindings() ) {
                            policyDefinitionsResolver.addModel(binding);
                        }
                    }
                }
            }
        }

        for (URI anArtifactUri : compositeUris) {
            URL artifactURL = packageProcessor.getArtifactURL(new URL(contribution.getLocation()), anArtifactUri);

            // Add the deployed artifact model to the resolver
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(anArtifactUri.toString());
            artifact.setLocation(artifactURL.toString());
            contribution.getArtifacts().add(artifact);
            modelResolver.addModel(artifact);

            model = this.artifactProcessor.read(contributionURL, anArtifactUri, artifactURL);
            if (model != null) {
                artifact.setModel(model);
                // Add the loaded model to the model resolver
                modelResolver.addModel(model);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.Artifact

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.