Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.catalina.startup;
 
 
 import java.io.File;
 
Startup event listener for a Host that configures the properties of that Host, and the associated defined contexts.

Author(s):
Craig R. McClanahan
Remy Maucherat
Version:
$Revision: 1543 $ $Date: 2010-08-26 11:45:16 +0200 (Thu, 26 Aug 2010) $
 
 public class HostConfig
     implements LifecycleListener {
     
     // ----------------------------------------------------- Instance Variables
 

    
App base.
 
     protected File appBase = null;


    
Config base.
 
     protected File configBase = null;


    
The Java class name of the Context configuration class we should use.
 
     protected String configClass = "org.apache.catalina.startup.ContextConfig";


    
The Java class name of the Context implementation we should use.
 
     protected String contextClass = "org.apache.catalina.core.StandardContext";


    
The Host we are associated with.
 
     protected Host host = null;

    
    
List of applications which are being serviced, and shouldn't be deployed/undeployed/redeployed at the moment.
 
     protected ArrayList<Stringserviced = new ArrayList<String>();
     
 
     // ------------------------------------------------------------- Properties
 

    
Return the Context configuration class name.
 
     public String getConfigClass() {
 
         return (this.);
 
     }


    
Set the Context configuration class name.

Parameters:
configClass The new Context configuration class name.
    public void setConfigClass(String configClass) {
        this. = configClass;
    }


    
Return the Context implementation class name.
    public String getContextClass() {
        return (this.);
    }


    
Set the Context implementation class name.

Parameters:
contextClass The new Context implementation class name.
    public void setContextClass(String contextClass) {
        this. = contextClass;
    }
    // --------------------------------------------------------- Public Methods


    
Process the START event for an associated Host.

Parameters:
event The lifecycle event that has occurred
    public void lifecycleEvent(LifecycleEvent event) {
        // Identify the context we are associated with
         = (Hostevent.getLifecycle();
        
        if (event.getType().equals(.))
            check();
        // Process the event that has occurred
        if (event.getType().equals(.))
            start();
        else if (event.getType().equals(.))
            stop();
    }
    
    // ------------------------------------------------------ Protected Methods

    
    
Return a File object representing the "application root" directory for our associated Host.
    protected File appBase() {
        if ( != null) {
            return ;
        }
        File file = new File(.getAppBase());
        if (!file.isAbsolute())
            file = new File(System.getProperty("catalina.base"),
                            .getAppBase());
        try {
             = file.getCanonicalFile();
        } catch (IOException e) {
             = file;
        }
        return ();
    }


    
Return a File object representing the "configuration root" directory for our associated Host.
    protected File configBase() {
        if ( != null) {
            return ;
        }
        File file = new File(System.getProperty("catalina.base"), "conf");
        Container parent = .getParent();
        if ((parent != null) && (parent instanceof Engine)) {
            file = new File(fileparent.getName());
        }
        file = new File(file.getName());
        try {
             = file.getCanonicalFile();
        } catch (IOException e) {
             = file;
        }
        return ();
    }

    
Get the name of the configBase. For use with JMX management.
    public String getConfigBaseName() {
        return configBase().getAbsolutePath();
    }

    
Given a context path, get the config file name.
    protected String getConfigFile(String path) {
        String basename = null;
        if (path.equals("")) {
            basename = "ROOT";
        } else {
            basename = path.substring(1).replace('/''#');
        }
        return (basename);
    }

    
    
Given a context path, get the docBase.
    protected String getDocBase(String path) {
        String basename = null;
        if (path.equals("")) {
            basename = "ROOT";
        } else {
            basename = path.substring(1).replace('/''#');
        }
        return (basename);
    }

    
    
Process a "start" event for this Host.
    public void start() {
    }


    
Process a "stop" event for this Host.
    public void stop() {
        undeployApps();
         = null;
         = null;
    }


    
Undeploy all deployed applications.
    protected void undeployApps() {
    }


    
Check status of all webapps.
    protected void check() {
    }
    
New to GrepCode? Check out our FAQ X