1 |
| package photospace.vfs; |
2 |
| |
3 |
| import java.io.*; |
4 |
| import org.apache.slide.common.*; |
5 |
| import org.springframework.context.*; |
6 |
| import org.springframework.core.io.*; |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| public class SlideContext |
17 |
| implements java.io.Serializable, ResourceLoaderAware |
18 |
| { |
19 |
| |
20 |
| private static final String TOKEN = "@media.root@"; |
21 |
| |
22 |
| private FileSystem filesystem; |
23 |
| private String config; |
24 |
| private ResourceLoader resourceLoader; |
25 |
| |
26 |
0
| public void init()
|
27 |
| throws Exception |
28 |
| { |
29 |
0
| BufferedReader reader = new BufferedReader(new FileReader(resourceLoader.getResource(config).getFile()));
|
30 |
0
| StringBuffer content = new StringBuffer();
|
31 |
0
| String line = null;
|
32 |
0
| while ((line = reader.readLine()) != null)
|
33 |
| { |
34 |
0
| int pos = line.indexOf(TOKEN);
|
35 |
0
| if (pos != -1)
|
36 |
| { |
37 |
0
| line = line.substring(0, pos) +
|
38 |
| filesystem.getRoot().getPath().replaceAll("\\\\", "/") + |
39 |
| line.substring(pos + TOKEN.length()); |
40 |
| } |
41 |
0
| content.append(line);
|
42 |
| } |
43 |
0
| InputStream in = new ByteArrayInputStream(content.toString().getBytes());
|
44 |
0
| Domain.init(in);
|
45 |
| } |
46 |
| |
47 |
0
| public void setFilesystem(FileSystem filesystem)
|
48 |
| { |
49 |
0
| this.filesystem = filesystem;
|
50 |
| } |
51 |
| |
52 |
0
| public void setConfig(String config)
|
53 |
| { |
54 |
0
| this.config = config;
|
55 |
| } |
56 |
| |
57 |
| |
58 |
0
| public void setResourceLoader(ResourceLoader resourceLoader)
|
59 |
| { |
60 |
0
| this.resourceLoader = resourceLoader;
|
61 |
| } |
62 |
| } |