incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1388050 - in /incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource: ResourceStreamSourceChainOfResponsibility.java ResourceStreamSourceComposite.java
Date Thu, 20 Sep 2012 14:43:59 GMT
Author: danhaywood
Date: Thu Sep 20 14:43:59 2012
New Revision: 1388050

URL: http://svn.apache.org/viewvc?rev=1388050&view=rev
Log:
ISIS-262: support ResourceStreamSourceComposite

applying patch from Minto van der Sluis

Added:
    incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java
      - copied, changed from r1387993, incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java
Modified:
    incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java?rev=1388050&r1=1388049&r2=1388050&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java
(original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java
Thu Sep 20 14:43:59 2012
@@ -69,7 +69,7 @@ public class ResourceStreamSourceChainOf
 
     @Override
     public String getName() {
-        return "[" + resourceStreamNames() + "]";
+        return "chain [" + resourceStreamNames() + "]";
     }
 
     private String resourceStreamNames() {

Copied: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java
(from r1387993, incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java?p2=incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java&p1=incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java&r1=1387993&r2=1388050&rev=1388050&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceChainOfResponsibility.java
(original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java
Thu Sep 20 14:43:59 2012
@@ -21,18 +21,20 @@ package org.apache.isis.core.commons.res
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.SequenceInputStream;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Vector;
 
 import org.apache.log4j.Logger;
 
-public class ResourceStreamSourceChainOfResponsibility extends ResourceStreamSourceAbstract
{
+public class ResourceStreamSourceComposite extends ResourceStreamSourceAbstract {
 
-    private static Logger LOG = Logger.getLogger(ResourceStreamSourceChainOfResponsibility.class);
+    private static Logger LOG = Logger.getLogger(ResourceStreamSourceComposite.class);
 
     private final List<ResourceStreamSource> resourceStreamSources = new ArrayList<ResourceStreamSource>();
 
-    public ResourceStreamSourceChainOfResponsibility(final ResourceStreamSource... resourceStreamSources)
{
+    public ResourceStreamSourceComposite(final ResourceStreamSource... resourceStreamSources)
{
         for (final ResourceStreamSource rss : resourceStreamSources) {
             addResourceStreamSource(rss);
         }
@@ -44,12 +46,16 @@ public class ResourceStreamSourceChainOf
 
     @Override
     protected InputStream doReadResource(final String resourcePath) {
+        Vector<InputStream> compositionStreams = new Vector<InputStream>();
         for (final ResourceStreamSource rss : resourceStreamSources) {
             final InputStream resourceStream = rss.readResource(resourcePath);
             if (resourceStream != null) {
-                return resourceStream;
+                compositionStreams.add(resourceStream);
             }
         }
+        if (!compositionStreams.isEmpty()) {
+            return new SequenceInputStream(compositionStreams.elements());
+        }
         if (LOG.isDebugEnabled()) {
             LOG.debug("could not load resource path '" + resourcePath + "' from " + getName());
         }
@@ -58,18 +64,12 @@ public class ResourceStreamSourceChainOf
 
     @Override
     public OutputStream writeResource(final String resourcePath) {
-        for (final ResourceStreamSource rss : resourceStreamSources) {
-            final OutputStream os = rss.writeResource(resourcePath);
-            if (os != null) {
-                return os;
-            }
-        }
-        return null;
+        return null; // No support for writing resources
     }
 
     @Override
     public String getName() {
-        return "[" + resourceStreamNames() + "]";
+        return "composite [" + resourceStreamNames() + "]";
     }
 
     private String resourceStreamNames() {



Mime
View raw message