view src/kryshen/catalina/startup/HomesUserConfig.java @ 12:2f82b0faeb89

Javadoc.
author Mikhail Kryshen <mikhail@kryshen.net>
date Tue, 03 Nov 2009 00:36:43 +0300
parents 3a71cbe721f9
children 618d0df5d46c
line wrap: on
line source

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kryshen.catalina.startup;

import java.io.File;
import org.apache.juli.logging.LogFactory;

/**
 * Event listener for Host that deploys and updates applications 
 * provided by users. Files in the specified base directory are 
 * considered tp be user home directories.
 *
 * @author Mikhail Kryshen
 */
public class HomesUserConfig extends UserConfig {

    /**
     * The base directory containing user home directories.
     */
    private String homeBase = null;


    public HomesUserConfig() {
        log = LogFactory.getLog(HomesUserConfig.class);
    }

    /**
     * Return the base directory containing user home directories.
     */
    public String getHomeBase() {
        return homeBase;
    }

    /**
     * Set the base directory containing user home directories.
     *
     * @param homeBase The new base directory
     */
    public void setHomeBase(String homeBase) {
        this.homeBase = homeBase;
    }

    @Override
    protected void deployUserApps() {
        File homeBaseFile = new File(homeBase);

        if (!homeBaseFile.isDirectory()) {
            log.error("Invalid home base.");
            return;
        }

        String[] homes = homeBaseFile.list();

        for (String name : homes) {
            File home = new File(homeBaseFile, name);
            
            if (!home.isDirectory() /* || !home.canExecute() */) {
                continue;
            }

            deployUserApps(name, home);
        }
    }
}