读懂tomact源码4:Host

Host

一个host在tomact中代表一个虚拟host,一般在下列情况下有用的:

  1. 你希望用拦截器来查看铁定的虚拟host的所有请求;
  2. 需要在tomact中用一个connector,但是需要多个虚拟host

StandardHost

Properties

  1. private String[] aliases = new String[0];
    private final Object aliasesLock = new Object();
    当前host的别名
  2. private String appBase = “webapps”;
     当前host的应用程序根
    private String xmlBase = null;
    当前程序的xml的根
  3. private boolean autoDeploy = true;
    host自动部署的标志
  4. Context相关
     private String configClass = “org.apache.catalina.startup.ContextConfig”;
    The Java class name of the default context configuration class for deployed web applications.
    private String contextClass = “org.apache.catalina.core.StandardContext”;
    The Java class name of the default Context implementation class for deployed web applications.
  5. private boolean deployOnStartup = true;
     当前host启动的标志
  6. private boolean deployXML = !Globals.IS_SECURITY_ENABLED;
    deploy Context XML config files property.
  7. private boolean copyXML = false;
      Should XML files be copied to $CATALINA_BASE/conf/<engine>/<host> by default when a web application is deployed?
      一般的情况
  <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true"/>
  1. private String errorReportValveClass = “org.apache.catalina.valves.ErrorReportValve”;
    The Java class name of the default error reporter implementation class
    for deployed web applications.
  2. private static final String info = “org.apache.catalina.core.StandardHost/1.0”;
    The descriptive information string for this implementation.
  3. private boolean unpackWARs = true;
    Unpack WARs property.
  4. private String workDir = null;
    Work Directory base for applications.
  5. private boolean createDirs = true;
    Should we create directories upon startup for appBase and xmlBase
  6. childClassLoaders
private Map<ClassLoader, String> childClassLoaders = new WeakHashMap<ClassLoader, String>();

Track the class loaders for the child web applications so memory leaks can be detected.
14. private Pattern deployIgnore = null;
Any file or directory in appBase that this pattern matches will be ignored by the automatic deployment process (both deployOnStartup autoDeploy).
15. private boolean undeployOldVersions = false;
16. private boolean failCtxIfServletStartFails = false;

Set Properties

在属性的设置方法里,可以看到同一个方法firePropertyChange,我们来看下这个方法.
Reports a boolean bound property update to listeners that have been registered to track updates of all properties or a property with the specified name. No event is fired if old and new values are equal. This is merely a convenience wrapper around the more general

HostConfig

 Startup event listener for a Host< that configures the properties of that Host, and the associated defined contexts.
   /**
     * Deploy applications for any directories or WAR files that are found
     * in our "application root" directory.
     */
    protected void deployApps() {

        File appBase = appBase();
        File configBase = configBase();
        String[] filteredAppPaths = filterAppPaths(appBase.list());
        // Deploy XML descriptors from configBase
        deployDescriptors(configBase, configBase.list());
        // Deploy WARs
        deployWARs(appBase, filteredAppPaths);
        // Deploy expanded folders
        deployDirectories(appBase, filteredAppPaths);

    }

理一下过程:

  1. Return a File object representing the “application root” directory for our associated Host.
  2. Return a File object representing the “configuration root” directory for our associated Host.
  3. Filter the list of application file paths to remove those that match the regular expression defined by Host.getDeployIgnore()
  4. Deploy XML context descriptors
  5. Deploy WAR files
  6. Deploy directories
    HostConfig的内容,以后会详细的学习下.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值