AutoDeployedFilesManager.javaAPI DocGlassfish v2 API11306Sun May 13 15:19:38 BST 2007com.sun.enterprise.deployment.autodeploy


public class AutoDeployedFilesManager extends Object
Contains the status of list of files that have been autodeployed.
Mahesh Rangamani

Fields Summary
private static final Logger
static final String
protected String
Constructors Summary
public AutoDeployedFilesManager()

protected AutoDeployedFilesManager(String s)

        statDir = s;
Methods Summary
protected static f)

        File undeployRequest = new File(f.getPath() + AutoDeployConstants.UNDEPLOY_REQUESTED);
        return undeployRequest;
public voiddeleteDeployedFileInfo( f)

      try {
        File statusFile = getStatusFile(f);
      } catch (Exception e) { throw e;}
private voiddeleteJbiDeployedFileInfo( f)
Delete the JBI status file.

      try {
        JBIAutoDeployer jad = JBIAutoDeployer.getInstance();
        File statusFile = jad.getStatusFile(f, new File(statDir));
        if (statusFile != null)
      } catch (Exception e) { throw e;}
public[]getFilesForDeployment([] latestFiles)
Compare the list of files with the current status info and determine the files that need to be deployed

        if (latestFiles == null) return new File[0];

        ArrayList<File> arrList = new ArrayList<File>();
        for (File deployDirFile : latestFiles) {
            File statusFile = getStatusFile(deployDirFile);
            if (!statusFile.exists() || deployDirFile.lastModified() != statusFile.lastModified()) {            
        return arrList.toArray(new File[0]);
public[]getFilesForUndeployment([] latestFiles)
Compare the list of files with the current status info and determine the apps that need to be undeployed.

        File statusDir = new File(statDir);  
        Set<File> statusFiles = 
                AutoDeployDirectoryScanner.getListOfFilesAsSet(statusDir, true);
        // The file might have been deleted. In that case, return null.
        if (statusFiles == null || statusFiles.isEmpty()){
            return null;
        // now let's get the latestFiles status files names to remove them 
        // from the list of status files, any remaining ones will need to 
        // be undeployed
        for (File deployDirFile : latestFiles) {
        ArrayList<File> appNames = new ArrayList<File>();
        File autodeployDir = statusDir.getParentFile();        
        for(File statusDirFile : statusFiles) {
            // calculate the original file as it was copied in the autodeploy
            // directory
            File filePath = statusDir.getParentFile();
            File f = statusDirFile.getParentFile();
            while (!f.equals(statusDir)) {
                filePath = new File(filePath, f.getName());
                f = f.getParentFile();
            filePath  = new File(filePath,  statusDirFile.getName());
        // Add to the app names files any entries for which auto-undeployment
        // has been requested by the user's creation of xxx_undeploy_requested.
        return appNames.toArray(new File[0]);
private java.util.CollectiongetFilesToUndeployByRequest([] latestFiles)

        ArrayList<File> appsRequested = new ArrayList<File>();
        for (File f : latestFiles) {
             * See if there is a corresponding _undeployRequested file for this
             * file.
            if (isUndeployRequested(f)) {
                appsRequested.add(new UndeployRequestedFile(f));
        if (sLogger.isLoggable(Level.FINE) && ! appsRequested.isEmpty()) {
            StringBuilder sb = new StringBuilder("Undeployment requested using *_undeployRequested for ");
            for (File app : appsRequested) {
                sb.append("  " + app.getName() + System.getProperty("line.separator"));
        return appsRequested;
private f)

        File outDir = new File(this.statDir);
        outDir = obtainFileStatusDir(f, outDir, outDir.getParentFile());
        return new File(outDir, f.getName());
private static booleanisUndeployRequested( f)

        return appToUndeployRequestFile(f).exists();
public static com.sun.enterprise.deployment.autodeploy.AutoDeployedFilesManagerloadStatus( statusDir)
Create an instance from the persisted file in the specified directory.

statusDir Directory in which the status file is to read.

        return loadStatus(statusDir.getAbsolutePath());
public static com.sun.enterprise.deployment.autodeploy.AutoDeployedFilesManagerloadStatus(java.lang.String autoDeploymentDir)

        String statusDir = autoDeploymentDir + File.separator + STATUS_DIR_NAME;
        String sysAppDirPath = System.getProperty(Constants.INSTALL_ROOT) +
            File.separator + Constants.LIB + File.separator + 
            Constants.LIB_INSTALL + File.separator + 

        File fileObj = new File(statusDir);
        // if the .autodeploystatus directory does not exist 
        // and this is not for auto deploying system applications
        // create the .autodeploystatus directory
        if (!fileObj.exists() && !autoDeploymentDir.equals(sysAppDirPath)) {
        	sLogger.log(Level.INFO, "autoDeployment status dir missing, creating a new one");
        AutoDeployedFilesManager adfm = new AutoDeployedFilesManager(statusDir);
        return adfm;
static f, statDir, autoDeployDir)

        File dir = f.getParentFile();
        while (!dir.getAbsolutePath().equals(autoDeployDir.getAbsolutePath())) {
            statDir = new File(statDir, dir.getName()); 
            dir = dir.getParentFile();
        return statDir;
public voidsetDeployedFileInfo( f)
Update the status of the file as deployed.

      try {
        File statusFile = getStatusFile(f);
      } catch (Exception e) { throw e; }
private voidsetJbiDeployedFileInfo( f)
Create the JBI status file.

      try {
        JBIAutoDeployer jad = JBIAutoDeployer.getInstance();
        File statusFile = jad.getStatusFile(f, new File(statDir));
        if (statusFile != null)
      } catch (Exception e) { throw e; }
public voidwriteStatus()

           // Nothing to do