You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/03/06 00:18:07 UTC

svn commit: r514912 - in /incubator/tuscany/branches/sca-java-integration/sca/kernel: core/src/main/java/org/apache/tuscany/core/runtime/mini/ core/src/main/java/org/apache/tuscany/core/services/deployment/ core/src/main/java/org/apache/tuscany/core/se...

Author: lresende
Date: Mon Mar  5 15:18:05 2007
New Revision: 514912

URL: http://svn.apache.org/viewvc?view=rev&rev=514912
Log:
Contribution services - resolving model objects generated by processing scdl/composite files

Added:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/resolver/
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/resolver/ComponentDefinitionArtifactResolver.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java
Modified:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/mini/SimpleRuntimeImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/deployment.scdl
    incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/mini/SimpleRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/mini/SimpleRuntimeImpl.java?view=diff&rev=514912&r1=514911&r2=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/mini/SimpleRuntimeImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/mini/SimpleRuntimeImpl.java Mon Mar  5 15:18:05 2007
@@ -91,7 +91,7 @@
         URI compositeDefinitionId = contributionId.resolve(runtimeInfo.getCompositePath());
 
         application =
-            (CompositeComponent)assemblyService.addCompositeToDomain(contributionId, compositeDefinitionId);
+            (CompositeComponent)assemblyService.addCompositeToDomain(contributionId, compositeDefinitionId, runtimeInfo.getCompositePath());
 
         CompositeContext context = new CompositeContextImpl(application, getWireService());
         CurrentCompositeContext.setContext(context);

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java?view=diff&rev=514912&r1=514911&r2=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java Mon Mar  5 15:18:05 2007
@@ -64,14 +64,18 @@
         this.domain = domain;
     }
 
-    public Object addCompositeToDomain(URI contribution, URI composite) throws DeploymentException {
+    public Object addCompositeToDomain(URI contribution, URI composite, String artifactName) throws DeploymentException {
 
         Contribution contributionMetadata =
             (Contribution)this.contributionService.getContribution(contribution);
-        DeployedArtifact scdlArtifact = contributionMetadata.getArtifacts().get(composite);
+        /*DeployedArtifact scdlArtifact = contributionMetadata.getArtifacts().get(composite);
+        
         ComponentDefinition model =
-            (ComponentDefinition)scdlArtifact.getModelObject(CompositeComponentType.class, null);
+            (ComponentDefinition)scdlArtifact.getModelObject(CompositeComponentType.class, null);*/
 
+        ComponentDefinition model = 
+            (ComponentDefinition) this.contributionService.resolve(contribution, ComponentDefinition.class, null, artifactName);
+        
         Component component = null;
         Deployer deployer = null;
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java?view=diff&rev=514912&r1=514911&r2=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java Mon Mar  5 15:18:05 2007
@@ -72,7 +72,7 @@
      * @return
      * @throws IOException
      */
-    protected List<URL> getArtifacts(URL rootURL, InputStream sourceInputStream) throws DeploymentException,
+    protected List<URL> getArtifacts(URL rootURL) throws DeploymentException,
         IOException {
         List<URL> artifacts = new ArrayList<URL>();
 
@@ -104,7 +104,7 @@
 
         URL contributionURL = contribution.getArtifact(source).getLocation();
 
-        for (URL artifactURL : getArtifacts(contributionURL, inputStream)) {
+        for (URL artifactURL : getArtifacts(contributionURL)) {
             String artifactPath = artifactURL.toExternalForm().substring(contributionURL.toExternalForm().length());
             URI artifactURI = contribution.getUri().resolve(artifactPath);
             DeployedArtifact artifact = new DeployedArtifact(artifactURI);

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/resolver/ComponentDefinitionArtifactResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/resolver/ComponentDefinitionArtifactResolver.java?view=auto&rev=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/resolver/ComponentDefinitionArtifactResolver.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/resolver/ComponentDefinitionArtifactResolver.java Mon Mar  5 15:18:05 2007
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.services.deployment.resolver;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.deployer.ArtifactResolver;
+import org.apache.tuscany.spi.deployer.ArtifactResolverRegistry;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ArtifactResolverExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Contribution;
+import org.apache.tuscany.spi.model.DeployedArtifact;
+
+public class ComponentDefinitionArtifactResolver extends ArtifactResolverExtension implements ArtifactResolver {
+
+    public ComponentDefinitionArtifactResolver(@Autowire ArtifactResolverRegistry registry) {
+        super(registry);
+    }
+    
+    @Override
+    public Class<?> getType(){
+        return ComponentDefinition.class;
+    }
+
+    public <ComponentDefinition> ComponentDefinition resolve(Contribution contribution,
+                         Class<ComponentDefinition> modelClass,
+                         String namespace,
+                         String name,
+                         Map attributes,
+                         DeploymentContext context) {
+        
+        
+        //generate artifact uri based on it's name
+        URI artifactURI = contribution.getUri().resolve(name);
+        DeployedArtifact artifact = contribution.getArtifact(artifactURI);
+        
+        ComponentDefinition componentDefinition = (ComponentDefinition) artifact.getModelObject(CompositeComponentType.class, null);
+        return componentDefinition;
+    }
+
+    public URL resolve(Contribution contribution, String targetNamespace, String location, String baseURI) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/deployment.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/deployment.scdl?view=diff&rev=514912&r1=514911&r2=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/deployment.scdl (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/resources/org/apache/tuscany/core/deployment.scdl Mon Mar  5 15:18:05 2007
@@ -38,14 +38,11 @@
         <property name="repository">target/repository</property>
     </component>
 
+    <!-- contribution processor registry and processors -->
     <component name="contributionProcessorRegistry" initLevel="35">
         <system:implementation.system class="org.apache.tuscany.core.services.deployment.ContributionProcessorRegistryImpl" />
     </component>
 
-    <component name="artifactResolverRegistry" initLevel="35">
-        <system:implementation.system class="org.apache.tuscany.core.services.deployment.ArtifactResolverRegistryImpl" />
-    </component>
-
     <component name="contentTypeDescriber" initLevel="30">
         <system:implementation.system class="org.apache.tuscany.core.services.deployment.ContentTypeDescriberImpl" />
     </component>
@@ -60,6 +57,15 @@
     </component>
     <component name="ScdlContributionProcessor" initLevel="30">
         <system:implementation.system class="org.apache.tuscany.core.services.deployment.contribution.ScdlContributionProcessor" />
+    </component>    
+
+	<!-- contribution resolver registry and resolvers -->
+    <component name="artifactResolverRegistry" initLevel="35">
+        <system:implementation.system class="org.apache.tuscany.core.services.deployment.ArtifactResolverRegistryImpl" />
+    </component>
+
+    <component name="ComponentDefinitionArtifactResolver" initLevel="30">
+        <system:implementation.system class="org.apache.tuscany.core.services.deployment.resolver.ComponentDefinitionArtifactResolver" />
     </component>    
 
 </composite>

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java?view=diff&rev=514912&r1=514911&r2=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java Mon Mar  5 15:18:05 2007
@@ -43,7 +43,7 @@
      * @return The added composite
      * @throws DeploymentException
      */
-    Object addCompositeToDomain(URI contribution, URI composite) throws DeploymentException;
+    Object addCompositeToDomain(URI contribution, URI composite, String artifactName) throws DeploymentException;
 
     /**
      * Remove from the Domain Level composite the elements corresponding to the

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java?view=auto&rev=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java Mon Mar  5 15:18:05 2007
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.deployer.ArtifactResolver;
+import org.apache.tuscany.spi.deployer.ArtifactResolverRegistry;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * The base class for ContributionProcessor implementations
+ * 
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+@Service(ArtifactResolver.class)
+public abstract class ArtifactResolverExtension implements ArtifactResolver {
+    /**
+     * The ArtifactResolverRegistry that this resolver should register with; usually set by injection.
+     */
+    protected final ArtifactResolverRegistry registry;
+
+    /**
+     * @param registry the registry to set
+     */
+    @Constructor
+    public ArtifactResolverExtension(@Autowire ArtifactResolverRegistry registry) {
+        this.registry = registry;
+    }
+    
+    /**
+     * Initialize the resolver. It registers itself to the registry by model type it supports. 
+     */ 
+    @Init
+    public void start() {
+        this.registry.registerResolver(this.getType(), this);
+    }
+
+    /**
+     * Destroy the resolver. It unregisters itself from the registry. 
+     */
+    @Destroy
+    public void stop() {
+        registry.unregisterResolver(this.getType());
+    }
+
+    /**
+     * Returns the model type that this resolver can handle.
+     * 
+     * @return the model type that this resolver can handle
+     */
+    public abstract Class<?> getType();
+
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java?view=diff&rev=514912&r1=514911&r2=514912
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java Mon Mar  5 15:18:05 2007
@@ -48,14 +48,6 @@
         this.uri = uri;
     }
 
-    public Contribution getContribution() {
-        return contribution;
-    }
-
-    public void setContribution(Contribution contribution) {
-        this.contribution = contribution;
-    }
-
     /**
      * Get the absolute URI as the unique id for the artifact
      * @return
@@ -63,7 +55,29 @@
     public URI getUri() {
         return uri;
     }
+    
+    /**
+     * @return the location
+     */
+    public URL getLocation() {
+        return location;
+    }
 
+    /**
+     * @param location the location to set
+     */
+    public void setLocation(URL location) {
+        this.location = location;
+    }
+
+    public Contribution getContribution() {
+        return contribution;
+    }
+
+    public void setContribution(Contribution contribution) {
+        this.contribution = contribution;
+    }
+    
     public Map<Class, Map<String, Object>> getModelObjects() {
         return modelObjects;
     }
@@ -89,19 +103,4 @@
         }
         map.put(namespace, modelObject);
     }
-
-    /**
-     * @return the location
-     */
-    public URL getLocation() {
-        return location;
-    }
-
-    /**
-     * @param location the location to set
-     */
-    public void setLocation(URL location) {
-        this.location = location;
-    }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org