tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r655142 - in /incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl: ContributionCollectionImpl.java DeployedCompositeCollectionImpl.java DomainManagerUtil.java
Date Sat, 10 May 2008 19:25:18 GMT
Author: jsdelfino
Date: Sat May 10 12:25:18 2008
New Revision: 655142

URL: http://svn.apache.org/viewvc?rev=655142&view=rev
Log:
Improving the performance and robustness of the domain manager app. Switch back to ContributionInfoProcessor
when we're only interested in general info about contributions. Added some error checking
when contributions cannot be found. Centralized the logic to detect JAR files in DomainManagerUtil.

Modified:
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerUtil.java

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java?rev=655142&r1=655141&r2=655142&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java
Sat May 10 12:25:18 2008
@@ -57,12 +57,10 @@
 import org.apache.tuscany.sca.contribution.ContributionFactory;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
 import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
@@ -115,7 +113,6 @@
     private ContributionFactory contributionFactory;
     private WorkspaceFactory workspaceFactory;
     private StAXArtifactProcessor<Object> staxProcessor;
-    private URLArtifactProcessor<Object> urlProcessor;
     private URLArtifactProcessor<Contribution> contributionProcessor;
     private XMLInputFactory inputFactory;
     private XMLOutputFactory outputFactory;
@@ -141,19 +138,15 @@
         contributionFactory = modelFactories.getFactory(ContributionFactory.class);
         workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class);
         
-        // Create model resolvers
-        ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
-
         // Create artifact processors
         inputFactory = modelFactories.getFactory(XMLInputFactory.class);
         StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
         staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory,
outputFactory);
 
         URLArtifactProcessorExtensionPoint urlProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
-        urlProcessor = new ExtensibleURLArtifactProcessor(urlProcessors);
         
         // Create contribution info processor
-        contributionProcessor = urlProcessors.getProcessor(Contribution.class);
+        contributionProcessor = urlProcessors.getProcessor(".contribution/info");
 
         // Create a document builder (used to pretty print XML)
         documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
@@ -384,7 +377,10 @@
         }
         
         // List the dependency problems
-        if (problems.size() > 1) {
+        if (contribution.isUnresolved()) {
+            problems.add("Contribution not found");
+        }
+        if (problems.size() > 0) {
             sb.append("<span id=\"problems\" style=\"color: red\">");
             for (int i = 0, n = problems.size(); i < n ; i++) {
                 sb.append("Problem: "+ problems.get(i) + "<br>");
@@ -505,8 +501,15 @@
                 URL url = locationURL(c.getLocation());
                 try {
                     Contribution contribution = (Contribution)contributionProcessor.read(null,
uri, url);
+                    contribution.setUnresolved(false);
                     dependencyWorkspace.getContributions().add(contribution);
-                } catch (ContributionReadException e) {}
+                } catch (ContributionReadException e) {
+                    Contribution contribution = contributionFactory.createContribution();
+                    contribution.setURI(c.getURI());
+                    contribution.setLocation(c.getLocation());
+                    contribution.setUnresolved(true);
+                    dependencyWorkspace.getContributions().add(contribution);
+                }
             }
         } catch (Exception e) {
             throw new ServiceRuntimeException(e);

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java?rev=655142&r1=655141&r2=655142&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java
Sat May 10 12:25:18 2008
@@ -30,6 +30,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -59,10 +60,8 @@
 
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.xml.CompositeProcessor;
 import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.contribution.ContributionFactory;
-import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
@@ -206,24 +205,20 @@
             return;
         }
 
-        // Support reading source composite file inside a JAR
+        // Read the composite file and write to response
         String uri = item.getAlternate();
-        int e = uri.indexOf("!/"); 
-        if (e != -1) {
-            int s = uri.lastIndexOf('/', e - 2) +1;
-            if (uri.substring(s, e).contains(".")) {
-                uri = "jar:" + uri;
-            } else {
-                uri = uri.substring(0, e) + uri.substring(e + 1);
-            }
+        InputStream is;
+        try {
+            URLConnection connection = new URL(uri).openConnection();
+            connection.setUseCaches(false);
+            connection.connect();
+            is = connection.getInputStream();
+        } catch (FileNotFoundException ex) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
         }
-        
-        // Read the composite file and write to response
+
         response.setContentType("text/xml");
-        URLConnection connection = new URL(uri).openConnection();
-        connection.setUseCaches(false);
-        connection.connect();
-        InputStream is = connection.getInputStream();
         ServletOutputStream os = response.getOutputStream();
         byte[] buffer = new byte[4096];
         for (;;) {

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerUtil.java?rev=655142&r1=655141&r2=655142&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerUtil.java
(original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerUtil.java
Sat May 10 12:25:18 2008
@@ -151,22 +151,36 @@
      * @return
      */
     static String compositeAlternateLink(String contributionLocation, String deployableURI)
{
-        URI uri = URI.create(contributionLocation);
-        if ("file".equals(uri.getScheme())) {
-            String path = uri.toString().substring(5);
+        if (deployableURI == null) {
+            return null;
+        }
+        URI u = URI.create(contributionLocation);
+        String uri;
+        if ("file".equals(u.getScheme())) {
+            String path = u.toString().substring(5);
             File file = new File(path);
             if (file.isDirectory()) {
                 if (contributionLocation.endsWith("/")) {
-                    return contributionLocation + deployableURI;
+                    uri = contributionLocation + deployableURI;
                 } else {
-                    return contributionLocation + "/" + deployableURI;
+                    uri = contributionLocation + "/" + deployableURI;
                 }
             } else {
-                return contributionLocation + "!/" + deployableURI; 
+                uri = contributionLocation + "!/" + deployableURI; 
             }
         } else {
-            return contributionLocation + "!/" + deployableURI;
+            uri = contributionLocation + "!/" + deployableURI;
+        }
+        int e = uri.indexOf("!/"); 
+        if (e != -1) {
+            int s = uri.lastIndexOf('/', e - 2) +1;
+            if (uri.substring(s, e).contains(".")) {
+                uri = "jar:" + uri;
+            } else {
+                uri = uri.substring(0, e) + uri.substring(e + 1);
+            }
         }
+        return uri;
     }
 
     /**



Mime
View raw message