| 1 | |
package org.webslinger.container; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
|
| 5 | |
import org.apache.commons.vfs.FileObject; |
| 6 | |
|
| 7 | |
import org.webslinger.commons.vfs.VFSUtil; |
| 8 | |
import org.webslinger.util.TTLObject; |
| 9 | |
|
| 10 | 47 | public final class DefaultPathInfo extends TTLObject<String> implements PathInfo { |
| 11 | |
static { |
| 12 | 1 | setDefaultTTLForClass(DefaultPathInfo.class, 1000); |
| 13 | 1 | } |
| 14 | |
|
| 15 | |
private final FileObject file; |
| 16 | |
|
| 17 | 31 | public DefaultPathInfo(FileObject file) { |
| 18 | 31 | this.file = file; |
| 19 | 31 | } |
| 20 | |
|
| 21 | |
public final String getPathInfo() { |
| 22 | |
try { |
| 23 | 141 | return getObject(); |
| 24 | 0 | } catch (IOException e) { |
| 25 | 0 | return ""; |
| 26 | |
} |
| 27 | |
} |
| 28 | |
|
| 29 | |
protected String load(String old) throws IOException { |
| 30 | 47 | if (file.exists()) { |
| 31 | 47 | VFSUtil.refresh(file); |
| 32 | 47 | String pathInfo = (String) file.getContent().getAttribute("default-path-info"); |
| 33 | 47 | if (pathInfo != null) return pathInfo; |
| 34 | |
} |
| 35 | 43 | return ""; |
| 36 | |
} |
| 37 | |
|
| 38 | |
public final String toString() { |
| 39 | 0 | return getPathInfo(); |
| 40 | |
} |
| 41 | |
} |