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


    private void importWSDL(ImportSDO importSDO, ModelResolver resolver) throws ContributionResolveException {
        String location = importSDO.getSchemaLocation();
        if (location != null) {
            try {
                Artifact artifact = contributionFactory.createArtifact();
                artifact.setURI(location);
                artifact = resolver.resolveModel(Artifact.class, artifact);
                if (artifact.getLocation() != null) {
                  String wsdlURL = artifact.getLocation();
                    URLConnection connection = new URL(wsdlURL).openConnection();
                    connection.setUseCaches(false);
                    InputStream xsdInputStream = connection.getInputStream();
                    try {
                        XSDHelper xsdHelper = importSDO.getHelperContext().getXSDHelper();
View Full Code Here

            resolveContracts(component, component.getServices(), resolver);
            resolveContracts(component, component.getReferences(), resolver);
           
            for (ComponentProperty componentProperty : component.getProperties()) {
                if (componentProperty.getFile() != null) {
                    Artifact artifact = contributionFactory.createArtifact();
                    artifact.setURI(componentProperty.getFile());
                    artifact = resolver.resolveModel(Artifact.class, artifact);
                    if (artifact.getLocation() != null) {
                        componentProperty.setFile(artifact.getLocation());
                    }
                }
            }
           
            //resolve component implementation
View Full Code Here

     */
    public void resolve(XQueryImplementation xqueryImplementation, ModelResolver resolver)
        throws ContributionResolveException {
     
      if (xqueryImplementation != null) {
            Artifact artifact = contributionFactory.createArtifact();
            artifact.setURI(xqueryImplementation.getLocation());
          artifact = resolver.resolveModel(Artifact.class, artifact);
          if (artifact.getLocation() != null) {
            xqueryImplementation.setLocationURL(artifact.getLocation());
             
            XQueryIntrospector introspector = new XQueryIntrospector(assemblyFactory, javaFactory);
             
              boolean success = introspector.introspect(xqueryImplementation, resolver);
              if (success) {
View Full Code Here

    public void resolve(ModelResolver resolver) {
     
      if (scriptName != null) {
          //FIXME The contribution factory should be injected
          ContributionFactory contributionFactory = new DefaultContributionFactory();
            Artifact artifact = contributionFactory.createArtifact();
            artifact.setURI(scriptName);
            artifact = resolver.resolveModel(Artifact.class, artifact);
            if (artifact.getLocation() != null) {
                try {
                    scriptURL = new URL(artifact.getLocation());
                } catch (MalformedURLException e) {
                    throw new RuntimeException(e);
                }
            }
      }
View Full Code Here

                            Object object,
                            Document document,
                            String parent) {

        if (object instanceof Artifact) {
            Artifact artifact = (Artifact)object;

            if (!(object instanceof Contribution)) {

                String location = artifact.getLocation();

                try {

                    if (document == null) {
                        document = documents.get(SearchFields.ARTIFACT_FIELD + location);
View Full Code Here

    }

    public Object getDocumentKey(Object obj) {

        if (obj instanceof Artifact) {
            Artifact artifact = (Artifact)obj;
            String uri = artifact.getLocation();

            if (uri != null && uri.length() == 0) {
                return null;
            }
View Full Code Here

        List<String> artifactURIs = scanner.getArtifacts(contributionURL);
        for (String artifactURI: artifactURIs) {
            URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);

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

            // Read each artifact
            Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), 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 (policyDefinitionsResolver != null) {
                    addPolicyDefinitions(model);
                }

                // Merge contribution metadata into the contribution model
                if (model instanceof ContributionMetadata) {
                    contributionMetadata = true;
                    ContributionMetadata c = (ContributionMetadata)model;
                    contribution.getImports().addAll(c.getImports());
                    contribution.getExports().addAll(c.getExports());
                    contribution.getDeployables().addAll(c.getDeployables());
                    contribution.getExtensions().addAll(c.getExtensions());
                    contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
                }
            }
        }

        // If no sca-contribution.xml file was provided then just consider
        // all composites in the contribution as deployables
        if (!contributionMetadata) {
            for (Artifact artifact: artifacts) {
                if (artifact.getModel() instanceof Composite) {
                    contribution.getDeployables().add((Composite)artifact.getModel());
                }
            }

            // Add default contribution import and export
            DefaultImport defaultImport = contributionFactory.createDefaultImport();
View Full Code Here

        composite = configuration.getComposite();
       
        if(composite != null && composite.isUnresolved()) {
            ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
            Artifact compositeFile = contributionFactory.createArtifact();
            compositeFile.setUnresolved(true);
            compositeFile.setURI(composite.getURI());
            for (Contribution c : contributions) {
                ModelResolver resolver = c.getModelResolver();
                Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
                if (resolved != null && resolved.isUnresolved() == false) {
                    composite = (Composite) resolved.getModel();
                    break;
                }
            }
        }
View Full Code Here

    private String location(Contribution contribution, String uri) {
        if (uri != null && uri.startsWith("/")) {
            uri = uri.substring(1);
        }
        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(uri);
        ModelResolver resolver = contribution.getModelResolver();
        Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
        if (resolved != null && !resolved.isUnresolved()) {
            return resolved.getLocation();
        } else {
            return null;
        }
    }
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.