package org.jboss.fresh.deployer;
import org.apache.log4j.Logger;
import org.jboss.fresh.registry.RegistryContext;
import org.jboss.fresh.vfs.RootVFS;
import org.jboss.fresh.vfs.VFS;
import org.jboss.fresh.vfs.impl.DefaultRootVFS;
import org.jboss.aop.microcontainer.aspects.jmx.JMX;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
* @author uros
* @version $Revision: 3032 $
* @modified $Author: strukelj $
*/
@JMX(name = "FRESH:service=VFS.Root", exposedInterface = RootVFSServiceMBean.class)
public class RootVFSService extends RegistryNamingBinder implements RootVFSServiceMBean {
private static Logger log = Logger.getLogger(RootVFSService.class);
private RootVFS vfs;
private Properties props;
protected String getBindClass() {
return RootVFS.class.getName();
}
public void setAutomount(Properties p) {
props = p;
}
public Properties getAutomount() {
return props;
}
protected Object classToInstance(Class c) {
vfs = new DefaultRootVFS();
return vfs;
}
protected boolean bindByReference() {
return true;
}
public void doStart() throws Exception {
super.doStart();
if (props != null) {
RegistryContext ctx = new RegistryContext();
Set set = props.entrySet();
Iterator it = set.iterator();
while (it.hasNext()) {
Map.Entry ent = (Map.Entry) it.next();
String path = (String) ent.getKey();
String jndi = (String) ent.getValue();
VFS mvfs = (VFS) ctx.lookup(jndi);
vfs.mount(path, mvfs);
}
}
}
public String getName() {
return "CP2 Root VFS Binder Service";
}
}