use of org.apache.catalina.Context in project tomcat by apache.
the class DefaultServlet method validateGlobalXsltFile.
private File validateGlobalXsltFile() {
Context context = resources.getContext();
File baseConf = new File(context.getCatalinaBase(), "conf");
File result = validateGlobalXsltFile(baseConf);
if (result == null) {
File homeConf = new File(context.getCatalinaHome(), "conf");
if (!baseConf.equals(homeConf)) {
result = validateGlobalXsltFile(homeConf);
}
}
return result;
}
use of org.apache.catalina.Context in project tomcat by apache.
the class MBeanFactory method removeLoader.
/**
* Remove an existing Loader.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeLoader(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setLoader(null);
}
}
use of org.apache.catalina.Context in project tomcat by apache.
the class MBeanUtils method createObjectName.
/**
* Create an <code>ObjectName</code> for this
* <code>ContextResourceLink</code> object.
*
* @param domain Domain in which this name is to be created
* @param resourceLink The ContextResourceLink to be named
* @return a new object name
* @exception MalformedObjectNameException if a name cannot be created
*/
public static ObjectName createObjectName(String domain, ContextResourceLink resourceLink) throws MalformedObjectNameException {
ObjectName name = null;
String quotedResourceLinkName = ObjectName.quote(resourceLink.getName());
Object container = resourceLink.getNamingResources().getContainer();
if (container instanceof Server) {
name = new ObjectName(domain + ":type=ResourceLink" + ",resourcetype=Global" + ",name=" + quotedResourceLinkName);
} else if (container instanceof Context) {
Context context = ((Context) container);
ContextName cn = new ContextName(context.getName(), false);
Container host = context.getParent();
name = new ObjectName(domain + ":type=ResourceLink" + ",resourcetype=Context,host=" + host.getName() + ",context=" + cn.getDisplayName() + ",name=" + quotedResourceLinkName);
}
return (name);
}
use of org.apache.catalina.Context in project tomcat by apache.
the class MBeanUtils method createObjectName.
/**
* Create an <code>ObjectName</code> for this
* <code>ContextResource</code> object.
*
* @param domain Domain in which this name is to be created
* @param resource The ContextResource to be named
* @return a new object name
* @exception MalformedObjectNameException if a name cannot be created
*/
public static ObjectName createObjectName(String domain, ContextResource resource) throws MalformedObjectNameException {
ObjectName name = null;
String quotedResourceName = ObjectName.quote(resource.getName());
Object container = resource.getNamingResources().getContainer();
if (container instanceof Server) {
name = new ObjectName(domain + ":type=Resource" + ",resourcetype=Global,class=" + resource.getType() + ",name=" + quotedResourceName);
} else if (container instanceof Context) {
Context context = ((Context) container);
ContextName cn = new ContextName(context.getName(), false);
Container host = context.getParent();
name = new ObjectName(domain + ":type=Resource" + ",resourcetype=Context,host=" + host.getName() + ",context=" + cn.getDisplayName() + ",class=" + resource.getType() + ",name=" + quotedResourceName);
}
return (name);
}
use of org.apache.catalina.Context in project tomcat by apache.
the class UserConfig method deploy.
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
*/
private void deploy(String user, String home) {
// 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;
host.getLogger().info(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());
clazz = Class.forName(configClass);
LifecycleListener listener = (LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
host.addChild(context);
} catch (Exception e) {
host.getLogger().error(sm.getString("userConfig.error", user), e);
}
}
Aggregations