Fields Summary |
---|
private String | configClassThe Java class name of the Context configuration class we should use. |
private String | contextClassThe Java class name of the Context implementation we should use. |
private int | debugThe debugging detail level for this component. |
private String | directoryNameThe directory name to be searched for within each user home directory. |
private String | homeBaseThe base directory containing user home directories. |
private org.apache.catalina.Host | hostThe Host we are associated with. |
private static final org.apache.catalina.util.StringManager | smThe string resources for this package. |
private String | userClassThe Java class name of the user database class we should use. |
Methods Summary |
---|
private void | deploy()Deploy a web application for any user who has a web application present
in a directory with a specified name within their home directory.
if (debug >= 1)
log(sm.getString("userConfig.deploying"));
// Load the user database object for this host
UserDatabase database = null;
try {
Class clazz = Class.forName(userClass);
database = (UserDatabase) clazz.newInstance();
database.setUserConfig(this);
} catch (Exception e) {
log(sm.getString("userConfig.database"), e);
return;
}
// Deploy the web application (if any) for each defined user
Enumeration users = database.getUsers();
while (users.hasMoreElements()) {
String user = (String) users.nextElement();
String home = database.getHome(user);
deploy(user, home);
}
|
private void | deploy(java.lang.String user, java.lang.String home)Deploy a web application for the specified user if they have such an
application in the defined directory within their home directory.
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
File dd = new File(app, "/WEB-INF/web.xml");
if (!dd.exists() || !dd.isFile() || !dd.canRead())
return;
*/
log(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
if (context instanceof Lifecycle) {
clazz = Class.forName(configClass);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
host.addChild(context);
} catch (Exception e) {
log(sm.getString("userConfig.error", user), e);
}
|
public java.lang.String | getConfigClass()Return the Context configuration class name.
// ------------------------------------------------------------- Properties
return (this.configClass);
|
public java.lang.String | getContextClass()Return the Context implementation class name.
return (this.contextClass);
|
public int | getDebug()Return the debugging detail level for this component.
return (this.debug);
|
public java.lang.String | getDirectoryName()Return the directory name for user web applications.
return (this.directoryName);
|
public java.lang.String | getHomeBase()Return the base directory containing user home directories.
return (this.homeBase);
|
public java.lang.String | getUserClass()Return the user database class name for this component.
return (this.userClass);
|
public void | lifecycleEvent(org.apache.catalina.LifecycleEvent event)Process the START event for an associated Host.
// Identify the host we are associated with
try {
host = (Host) event.getLifecycle();
} catch (ClassCastException e) {
log(sm.getString("hostConfig.cce", event.getLifecycle()), e);
return;
}
// Process the event that has occurred
if (event.getType().equals(Lifecycle.START_EVENT))
start();
else if (event.getType().equals(Lifecycle.STOP_EVENT))
stop();
|
private void | log(java.lang.String message)Log a message on the Logger associated with our Host (if any)
Logger logger = null;
if (host != null)
logger = host.getLogger();
if (logger != null)
logger.log("UserConfig[" + host.getName() + "]: " + message);
else
System.out.println("UserConfig[" + host.getName() + "]: "
+ message);
|
private void | log(java.lang.String message, java.lang.Throwable throwable)Log a message on the Logger associated with our Host (if any)
Logger logger = null;
if (host != null)
logger = host.getLogger();
if (logger != null)
logger.log("UserConfig[" + host.getName() + "] "
+ message, throwable);
else {
System.out.println("UserConfig[" + host.getName() + "]: "
+ message);
System.out.println("" + throwable);
throwable.printStackTrace(System.out);
}
|
public void | setConfigClass(java.lang.String configClass)Set the Context configuration class name.
this.configClass = configClass;
|
public void | setContextClass(java.lang.String contextClass)Set the Context implementation class name.
this.contextClass = contextClass;
|
public void | setDebug(int debug)Set the debugging detail level for this component.
this.debug = debug;
|
public void | setDirectoryName(java.lang.String directoryName)Set the directory name for user web applications.
this.directoryName = directoryName;
|
public void | setHomeBase(java.lang.String homeBase)Set the base directory containing user home directories.
this.homeBase = homeBase;
|
public void | setUserClass(java.lang.String userClass)Set the user database class name for this component.
this.userClass = userClass;
|
private void | start()Process a "start" event for this Host.
if (debug > 0)
log(sm.getString("userConfig.start"));
deploy();
|
private void | stop()Process a "stop" event for this Host.
if (debug > 0)
log(sm.getString("userConfig.stop"));
|