blob: 1b103487062903a6b28b055c5631ba9197575db7 [file] [log] [blame]
Stuart McCulloch39cc9ac2012-07-16 13:43:38 +00001package aQute.bnd.osgi;
Stuart McCullochbb014372012-06-07 21:57:32 +00002
3import java.io.*;
4import java.util.*;
5
6public class CombinedResource extends WriteResource {
Stuart McCulloch2286f232012-06-15 13:27:53 +00007 final List<Resource> resources = new ArrayList<Resource>();
8 long lastModified = 0;
9
Stuart McCullochbb014372012-06-07 21:57:32 +000010 @Override
11 public void write(final OutputStream out) throws IOException, Exception {
12 OutputStream unclosable = new FilterOutputStream(out) {
Stuart McCulloch55d4dfe2012-08-07 10:57:21 +000013 @Override
Stuart McCullochbb014372012-06-07 21:57:32 +000014 public void close() {
15 // Ignore
16 }
17 };
Stuart McCulloch2286f232012-06-15 13:27:53 +000018 for (Resource r : resources) {
Stuart McCullochbb014372012-06-07 21:57:32 +000019 r.write(unclosable);
20 unclosable.flush();
21 }
22 }
23
24 @Override
25 public long lastModified() {
26 return lastModified;
27 }
28
29 public void addResource(Resource r) {
30 lastModified = Math.max(lastModified, r.lastModified());
31 resources.add(r);
32 }
33
Stuart McCullochbb014372012-06-07 21:57:32 +000034}