Ejemplo n.º 1
0
 /**
  * At terminate time, trigger a recursive delete of the directory if desired.
  *
  * @param status TerminationRecord object
  */
 @Override
 public synchronized void sfTerminateWith(TerminationRecord status) {
   super.sfTerminateWith(status);
   if (delete) {
     FileSystem.recursiveDelete(getFile());
   }
 }
Ejemplo n.º 2
0
  /**
   * read in the directory settings and bind the file attributes.
   *
   * @throws SmartFrogException failure while starting
   * @throws RemoteException In case of network/rmi error
   */
  @Override
  public synchronized void sfDeploy() throws SmartFrogException, RemoteException {
    super.sfDeploy();

    String dir;

    File parentDir = null;
    String parent;
    parent = FileSystem.lookupAbsolutePath(this, ATTR_PARENT, null, null, false, null);
    if (parent != null) {
      parentDir = new File(parent);
    }

    dir = FileSystem.lookupAbsolutePath(this, Mkdir.ATTR_DIR, null, parentDir, true, null);
    File directory = new File(dir);
    bind(directory);
    // get the delete flag
    // this is only done if the directory does not yet exist.
    // delete is implicitly false.
    delete = sfResolve(ATTR_DELETE_ON_EXIT, false, false);
  }
Ejemplo n.º 3
0
 /**
  * we only create the directory at startup time, even though we bond at deploy time.
  *
  * @throws SmartFrogException failure in starting
  * @throws RemoteException In case of network/rmi error
  */
 @Override
 public synchronized void sfStart() throws SmartFrogException, RemoteException {
   super.sfStart();
   File directory = getFile();
   boolean clean = sfResolve(ATTR_CLEAN_ON_START, false, false);
   if (directory.exists()) {
     if (clean) {
       FileSystem.recursiveDelete(directory);
     }
     // it already exists. that may be harmless, but it warns the component to not
     // delete the directory during termination.
     delete = false;
   }
   directory.mkdirs();
   if (!directory.exists() || !directory.isDirectory()) {
     // whatever it is, don't try and delete it.
     delete = false;
     // raise an error.
     throw new SmartFrogDeploymentException(
         "Failed to create directory " + directory.getAbsolutePath());
   }
   maybeStartTerminator("Mkdir");
 }