Stuart McCulloch | 42151ee | 2012-07-16 13:43:38 +0000 | [diff] [blame^] | 1 | package aQute.bnd.osgi; |
Stuart McCulloch | f317322 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 2 | |
| 3 | import java.io.*; |
| 4 | import java.util.*; |
| 5 | |
| 6 | public class CombinedResource extends WriteResource { |
Stuart McCulloch | 4482c70 | 2012-06-15 13:27:53 +0000 | [diff] [blame] | 7 | final List<Resource> resources = new ArrayList<Resource>(); |
| 8 | long lastModified = 0; |
| 9 | |
Stuart McCulloch | f317322 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 10 | @Override |
| 11 | public void write(final OutputStream out) throws IOException, Exception { |
| 12 | OutputStream unclosable = new FilterOutputStream(out) { |
| 13 | public void close() { |
| 14 | // Ignore |
| 15 | } |
| 16 | }; |
Stuart McCulloch | 4482c70 | 2012-06-15 13:27:53 +0000 | [diff] [blame] | 17 | for (Resource r : resources) { |
Stuart McCulloch | f317322 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 18 | r.write(unclosable); |
| 19 | unclosable.flush(); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | @Override |
| 24 | public long lastModified() { |
| 25 | return lastModified; |
| 26 | } |
| 27 | |
| 28 | public void addResource(Resource r) { |
| 29 | lastModified = Math.max(lastModified, r.lastModified()); |
| 30 | resources.add(r); |
| 31 | } |
| 32 | |
Stuart McCulloch | f317322 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 33 | } |