本文整理汇总了Java中org.apache.catalina.core.StandardContext.setDocBase方法的典型用法代码示例。如果您正苦于以下问题:Java StandardContext.setDocBase方法的具体用法?Java StandardContext.setDocBase怎么用?Java StandardContext.setDocBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.core.StandardContext
的用法示例。
在下文中一共展示了StandardContext.setDocBase方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addWebapp
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
public StandardContext addWebapp(StandardHost host,
String url, String path)
throws ServletException {
silence(url);
StandardContext ctx = new StandardContext();
ctx.setPath( url );
ctx.setDocBase(path);
if (defaultRealm == null) {
initSimpleAuth();
}
ctx.setRealm(defaultRealm);
initWebappDefaults(ctx);
ContextConfig ctxCfg = new ContextConfig();
ctx.addLifecycleListener( ctxCfg );
// prevent it from looking ( if it finds one - it'll have dup error )
ctxCfg.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML");
if (host == null) {
host = getHost();
}
host.addChild(ctx);
return ctx;
}
示例2: addContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
public StandardContext addContext(StandardHost host,
String contextPath,
String dir) {
silence(contextPath);
StandardContext ctx = new StandardContext();
ctx.setPath( contextPath );
ctx.setDocBase(dir);
ctx.addLifecycleListener(new FixContextListener());
if (host == null) {
host = getHost();
}
host.addChild(ctx);
return ctx;
}
示例3: createStandardContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create a new StandardContext.
*
* @param parent MBean Name of the associated parent component
* @param path The context path for this Context
* @param docBase Document base directory (or WAR) for this Context
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardContext(String parent, String path,
String docBase)
throws Exception {
// Create a new StandardContext instance
StandardContext context = new StandardContext();
path = getPathStr(path);
context.setPath(path);
context.setDocBase(docBase);
ContextConfig contextConfig = new ContextConfig();
context.addLifecycleListener(contextConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Server server = ServerFactory.getServer();
Service service = server.findService(pname.getKeyProperty("service"));
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
// Add context to the host
host.addChild(context);
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("StandardContext");
ObjectName oname =
MBeanUtils.createObjectName(managed.getDomain(), context);
return (oname.toString());
}
示例4: createStandardContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create a new StandardContext.
*
* @param parent MBean Name of the associated parent component
* @param path The context path for this Context
* @param docBase Document base directory (or WAR) for this Context
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardContext(String parent,
String path,
String docBase,
boolean xmlValidation,
boolean xmlNamespaceAware,
boolean tldValidation,
boolean tldNamespaceAware)
throws Exception {
// Create a new StandardContext instance
StandardContext context = new StandardContext();
path = getPathStr(path);
context.setPath(path);
context.setDocBase(docBase);
context.setXmlValidation(xmlValidation);
context.setXmlNamespaceAware(xmlNamespaceAware);
context.setTldValidation(tldValidation);
context.setTldNamespaceAware(tldNamespaceAware);
ContextConfig contextConfig = new ContextConfig();
context.addLifecycleListener(contextConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
ObjectName deployer = new ObjectName(pname.getDomain()+
":type=Deployer,host="+
pname.getKeyProperty("host"));
if(mserver.isRegistered(deployer)) {
String contextName = context.getName();
mserver.invoke(deployer, "addServiced",
new Object [] {contextName},
new String [] {"java.lang.String"});
String configPath = (String)mserver.getAttribute(deployer,
"configBaseName");
String baseName = context.getBaseName();
File configFile = new File(new File(configPath), baseName+".xml");
if (configFile.isFile()) {
context.setConfigFile(configFile.toURI().toURL());
}
mserver.invoke(deployer, "manageApp",
new Object[] {context},
new String[] {"org.apache.catalina.Context"});
mserver.invoke(deployer, "removeServiced",
new Object [] {contextName},
new String [] {"java.lang.String"});
} else {
log.warn("Deployer not found for "+pname.getKeyProperty("host"));
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
host.addChild(context);
}
// Return the corresponding MBean name
return context.getObjectName().toString();
}
示例5: createStandardContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create a new StandardContext.
*
* @param parent MBean Name of the associated parent component
* @param path The context path for this Context
* @param docBase Document base directory (or WAR) for this Context
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardContext(String parent,
String path,
String docBase,
boolean xmlValidation,
boolean xmlNamespaceAware,
boolean tldValidation,
boolean tldNamespaceAware)
throws Exception {
// Create a new StandardContext instance
StandardContext context = new StandardContext();
path = getPathStr(path);
context.setPath(path);
context.setDocBase(docBase);
context.setXmlValidation(xmlValidation);
context.setXmlNamespaceAware(xmlNamespaceAware);
context.setTldValidation(tldValidation);
context.setTldNamespaceAware(tldNamespaceAware);
ContextConfig contextConfig = new ContextConfig();
context.addLifecycleListener(contextConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
ObjectName deployer = new ObjectName(pname.getDomain()+
":type=Deployer,host="+
pname.getKeyProperty("host"));
if(mserver.isRegistered(deployer)) {
String contextPath = context.getPath();
mserver.invoke(deployer, "addServiced",
new Object [] {contextPath},
new String [] {"java.lang.String"});
String configPath = (String)mserver.getAttribute(deployer,
"configBaseName");
String baseName = getConfigFile(contextPath);
File configFile = new File(new File(configPath), baseName+".xml");
context.setConfigFile(configFile.getAbsolutePath());
mserver.invoke(deployer, "manageApp",
new Object[] {context},
new String[] {"org.apache.catalina.Context"});
mserver.invoke(deployer, "removeServiced",
new Object [] {contextPath},
new String [] {"java.lang.String"});
} else {
log.warn("Deployer not found for "+pname.getKeyProperty("host"));
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
host.addChild(context);
}
// Return the corresponding MBean name
ObjectName oname = context.getJmxName();
return (oname.toString());
}
示例6: createContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create, configure, and return a Context that will process all
* HTTP requests received from one of the associated Connectors,
* and directed to the specified context path on the virtual host
* to which this Context is connected.
* <p>
* After you have customized the properties, listeners, and Valves
* for this Context, you must attach it to the corresponding Host
* by calling:
* <pre>
* host.addChild(context);
* </pre>
* which will also cause the Context to be started if the Host has
* already been started.
*
* @param path Context path of this application ("" for the default
* application for this host, must start with a slash otherwise)
* @param docBase Absolute pathname to the document base directory
* for this web application
*
* @exception IllegalArgumentException if an invalid parameter
* is specified
*/
public Context createContext(String path, String docBase) {
if (debug >= 1)
logger.log("Creating context '" + path + "' with docBase '" +
docBase + "'");
StandardContext context = new StandardContext();
context.setDebug(debug);
context.setDocBase(docBase);
context.setPath(path);
ContextConfig config = new ContextConfig();
config.setDebug(debug);
((Lifecycle) context).addLifecycleListener(config);
return (context);
}
示例7: createStandardContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create a new StandardContext.
*
* @param parent
* MBean Name of the associated parent component
* @param path
* The context path for this Context
* @param docBase
* Document base directory (or WAR) for this Context
*
* @exception Exception
* if an MBean cannot be created or registered
*/
public String createStandardContext(String parent, String path, String docBase, boolean xmlValidation,
boolean xmlNamespaceAware, boolean tldValidation, boolean tldNamespaceAware) throws Exception {
Where.amI();
// Create a new StandardContext instance
StandardContext context = new StandardContext();
path = getPathStr(path);
context.setPath(path);
context.setDocBase(docBase);
context.setXmlValidation(xmlValidation);
context.setXmlNamespaceAware(xmlNamespaceAware);
context.setTldValidation(tldValidation);
context.setTldNamespaceAware(tldNamespaceAware);
ContextConfig contextConfig = new ContextConfig();
context.addLifecycleListener(contextConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
ObjectName deployer = new ObjectName(pname.getDomain() + ":type=Deployer,host=" + pname.getKeyProperty("host"));
if (mserver.isRegistered(deployer)) {
String contextName = context.getName();
mserver.invoke(deployer, "addServiced", new Object[] { contextName }, new String[] { "java.lang.String" });
String configPath = (String) mserver.getAttribute(deployer, "configBaseName");
String baseName = context.getBaseName();
File configFile = new File(new File(configPath), baseName + ".xml");
if (configFile.isFile()) {
context.setConfigFile(configFile.toURI().toURL());
}
mserver.invoke(deployer, "manageApp", new Object[] { context },
new String[] { "org.apache.catalina.Context" });
mserver.invoke(deployer, "removeServiced", new Object[] { contextName },
new String[] { "java.lang.String" });
} else {
log.warn("Deployer not found for " + pname.getKeyProperty("host"));
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
host.addChild(context);
}
// Return the corresponding MBean name
return context.getObjectName().toString();
}
示例8: createContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create, configure, and return a Context that will process all
* HTTP requests received from one of the associated Connectors,
* and directed to the specified context path on the virtual host
* to which this Context is connected.
* <p>
* After you have customized the properties, listeners, and Valves
* for this Context, you must attach it to the corresponding Host
* by calling:
* <pre>
* host.addChild(context);
* </pre>
* which will also cause the Context to be started if the Host has
* already been started.
*
* @param path Context path of this application ("" for the default
* application for this host, must start with a slash otherwise)
* @param docBase Absolute pathname to the document base directory
* for this web application
*
* @exception IllegalArgumentException if an invalid parameter
* is specified
*/
public Context createContext(String path, String docBase) {
if( log.isDebugEnabled() )
log.debug("Creating context '" + path + "' with docBase '" +
docBase + "'");
StandardContext context = new StandardContext();
context.setDocBase(docBase);
context.setPath(path);
ContextConfig config = new ContextConfig();
config.setCustomAuthenticators(authenticators);
context.addLifecycleListener(config);
return (context);
}
示例9: createContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create, configure, and return a Context that will process all
* HTTP requests received from one of the associated Connectors,
* and directed to the specified context path on the virtual host
* to which this Context is connected.
* <p>
* After you have customized the properties, listeners, and Valves
* for this Context, you must attach it to the corresponding Host
* by calling:
* <pre>
* host.addChild(context);
* </pre>
* which will also cause the Context to be started if the Host has
* already been started.
*
* @param path Context path of this application ("" for the default
* application for this host, must start with a slash otherwise)
* @param docBase Absolute pathname to the document base directory
* for this web application
*
* @exception IllegalArgumentException if an invalid parameter
* is specified
*/
public Context createContext(String path, String docBase) {
if( log.isDebugEnabled() )
log.debug("Creating context '" + path + "' with docBase '" +
docBase + "'");
StandardContext context = new StandardContext();
context.setDocBase(docBase);
context.setPath(path);
ContextConfig config = new ContextConfig();
config.setCustomAuthenticators(authenticators);
((Lifecycle) context).addLifecycleListener(config);
return (context);
}
示例10: createContext
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
/**
* Create, configure, and return a Context that will process all HTTP
* requests received from one of the associated Connectors, and directed to
* the specified context path on the virtual host to which this Context is
* connected.
* <p>
* After you have customized the properties, listeners, and Valves for this
* Context, you must attach it to the corresponding Host by calling:
*
* <pre>
* host.addChild(context);
* </pre>
*
* which will also cause the Context to be started if the Host has already
* been started.
*
* @param path
* Context path of this application ("" for the default
* application for this host, must start with a slash otherwise)
* @param docBase
* Absolute pathname to the document base directory for this web
* application
*
* @exception IllegalArgumentException
* if an invalid parameter is specified
*/
public Context createContext(String path, String docBase) {
if (log.isDebugEnabled())
log.debug("Creating context '" + path + "' with docBase '" + docBase + "'");
StandardContext context = new StandardContext();
context.setDocBase(docBase);
context.setPath(path);
ContextConfig config = new ContextConfig();
config.setCustomAuthenticators(authenticators);
context.addLifecycleListener(config);
return (context);
}