]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/vfs/VfsResourceFactory.java
157cc902fc3815573f4171305a685ecf887ee62c
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / vfs / VfsResourceFactory.java
1 package org.argeo.slc.vfs;
2
3 import org.apache.commons.vfs.CacheStrategy;
4 import org.apache.commons.vfs.FileSystemManager;
5 import org.apache.commons.vfs.impl.StandardFileSystemManager;
6 import org.springframework.beans.factory.FactoryBean;
7 import org.springframework.beans.factory.InitializingBean;
8 import org.springframework.core.io.Resource;
9
10 public class VfsResourceFactory implements FactoryBean, InitializingBean {
11 private String url;
12 private FileSystemManager fileSystemManager;
13
14 public Object getObject() throws Exception {
15 return new VfsResource(fileSystemManager.resolveFile(url));
16 }
17
18 public Class<?> getObjectType() {
19 return Resource.class;
20 }
21
22 public boolean isSingleton() {
23 return false;
24 }
25
26 public void afterPropertiesSet() throws Exception {
27 if (fileSystemManager == null) {
28 fileSystemManager = new StandardFileSystemManager();
29 ((StandardFileSystemManager) fileSystemManager)
30 .setCacheStrategy(CacheStrategy.ON_RESOLVE);
31 ((StandardFileSystemManager) fileSystemManager).init();
32 }
33
34 }
35
36 }