view src/kryshen/catalina/startup/HomesUserConfig.java @ 17:012d66bbc61f

README. Set default homeBase value.
author Mikhail Kryshen <mikhail@kryshen.net>
date Tue, 03 Nov 2009 03:32:45 +0300
parents 618d0df5d46c
children
line source
1 /*
2 * Copyright 2009 Mikhail Kryshen
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
17 package kryshen.catalina.startup;
19 import java.io.File;
20 import org.apache.juli.logging.LogFactory;
22 /**
23 * Event listener for Host that deploys and updates applications
24 * provided by users. Files in the specified base directory are
25 * considered tp be user home directories.
26 *
27 * @author Mikhail Kryshen
28 */
29 public class HomesUserConfig extends UserConfig {
31 /**
32 * The base directory containing user home directories.
33 */
34 private String homeBase = "/home";
37 public HomesUserConfig() {
38 log = LogFactory.getLog(HomesUserConfig.class);
39 }
41 /**
42 * Return the base directory containing user home directories.
43 */
44 public String getHomeBase() {
45 return homeBase;
46 }
48 /**
49 * Set the base directory containing user home directories.
50 *
51 * @param homeBase The new base directory
52 */
53 public void setHomeBase(String homeBase) {
54 this.homeBase = homeBase;
55 }
57 @Override
58 protected void deployUserApps() {
59 File homeBaseFile = new File(homeBase);
61 if (!homeBaseFile.isDirectory()) {
62 log.error("Invalid home base.");
63 return;
64 }
66 String[] homes = homeBaseFile.list();
68 for (String name : homes) {
69 File home = new File(homeBaseFile, name);
71 if (!home.isDirectory() /* || !home.canExecute() */) {
72 continue;
73 }
75 deployUserApps(name, home);
76 }
77 }
78 }