org.apache.activemq.artemis.utils.FileUtil.deleteDirectory()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.apache.activemq.artemis.utils.FileUtil.deleteDirectory()方法的一些代码示例,展示了FileUtil.deleteDirectory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.deleteDirectory()方法的具体详情如下:
包路径:org.apache.activemq.artemis.utils.FileUtil
类名称:FileUtil
方法名:deleteDirectory

FileUtil.deleteDirectory介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public static final boolean deleteDirectory(final File directory) {
 if (directory.isDirectory()) {
   String[] files = directory.list();
   int num = 5;
   int attempts = 0;
   while (files == null && (attempts < num)) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    files = directory.list();
    attempts++;
   }
   if (files == null) {
    ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
   } else {
    for (String file : files) {
      File f = new File(directory, file);
      if (!deleteDirectory(f)) {
       ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
      }
    }
   }
 }
 return directory.delete();
}

代码示例来源:origin: apache/activemq-artemis

@Override
public synchronized void removeFileFactory(SequentialFileFactory fileFactory) throws Exception {
 File directory = fileFactory.getDirectory();
 if (directory.exists()) {
   FileUtil.deleteDirectory(directory);
 }
}

代码示例来源:origin: apache/activemq-artemis

protected static final boolean deleteDirectory(final File directory) {
 return FileUtil.deleteDirectory(directory);
}

代码示例来源:origin: apache/activemq-artemis

public static final boolean deleteDirectory(final File directory) {
 if (directory.isDirectory()) {
   String[] files = directory.list();
   int num = 5;
   int attempts = 0;
   while (files == null && (attempts < num)) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    files = directory.list();
    attempts++;
   }
   if (files == null) {
    ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
   } else {
    for (String file : files) {
      File f = new File(directory, file);
      if (!deleteDirectory(f)) {
       ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
      }
    }
   }
 }
 return directory.delete();
}

代码示例来源:origin: org.apache.activemq/artemis-commons

public static final boolean deleteDirectory(final File directory) {
 if (directory.isDirectory()) {
   String[] files = directory.list();
   int num = 5;
   int attempts = 0;
   while (files == null && (attempts < num)) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    files = directory.list();
    attempts++;
   }
   if (files == null) {
    ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
   } else {
    for (String file : files) {
      File f = new File(directory, file);
      if (!deleteDirectory(f)) {
       ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
      }
    }
   }
 }
 return directory.delete();
}

代码示例来源:origin: apache/activemq-artemis

public static final boolean deleteDirectory(final File directory) {
 if (directory.isDirectory()) {
   String[] files = directory.list();
   int num = 5;
   int attempts = 0;
   while (files == null && (attempts < num)) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    files = directory.list();
    attempts++;
   }
   if (files == null) {
    ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
   } else {
    for (String file : files) {
      File f = new File(directory, file);
      if (!deleteDirectory(f)) {
       ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
      }
    }
   }
 }
 return directory.delete();
}

代码示例来源:origin: apache/activemq-artemis

public static final boolean deleteDirectory(final File directory) {
 if (directory.isDirectory()) {
   String[] files = directory.list();
   int num = 5;
   int attempts = 0;
   while (files == null && (attempts < num)) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    files = directory.list();
    attempts++;
   }
   if (files == null) {
    ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
   } else {
    for (String file : files) {
      File f = new File(directory, file);
      if (!deleteDirectory(f)) {
       ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
      }
    }
   }
 }
 return directory.delete();
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

public static final boolean deleteDirectory(final File directory) {
 if (directory.isDirectory()) {
   String[] files = directory.list();
   int num = 5;
   int attempts = 0;
   while (files == null && (attempts < num)) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    files = directory.list();
    attempts++;
   }
   if (files == null) {
    ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
   } else {
    for (String file : files) {
      File f = new File(directory, file);
      if (!deleteDirectory(f)) {
       ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
      }
    }
   }
 }
 return directory.delete();
}

代码示例来源:origin: org.apache.activemq/artemis-web

public void internalStop() throws Exception {
 server.stop();
 if (webContexts != null) {
   File tmpdir = null;
   for (WebAppContext context : webContexts) {
    tmpdir = context.getTempDirectory();
    if (tmpdir != null && !context.isPersistTempDirectory()) {
      //tmpdir will be removed by deleteOnExit()
      //somehow when broker is stopped and restarted quickly
      //this tmpdir won't get deleted sometimes
      boolean fileDeleted = TimeUtils.waitOnBoolean(false, 5000, tmpdir::exists);
      if (!fileDeleted) {
       //because the execution order of shutdown hooks are
       //not determined, so it's possible that the deleteOnExit
       //is executed after this hook, in that case we force a delete.
       FileUtil.deleteDirectory(tmpdir);
       logger.debug("Force to delete temporary file on shutdown: " + tmpdir.getAbsolutePath());
       if (tmpdir.exists()) {
         ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
       }
      }
    }
   }
   webContexts.clear();
 }
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void setUp() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void setUp() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void removeFolder() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 serverFolder.getRoot().mkdirs();
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void removeFolder() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 serverFolder.getRoot().mkdirs();
}

代码示例来源:origin: apache/activemq-artemis

@Before
@Override
public void setUp() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 serverFolder.getRoot().mkdirs();
 File file = serverFolder.newFile(ActiveMQJMSClient.class.getName() + ".properties");
 FileOutputStream fileOutputStream = new FileOutputStream(file);
 PrintStream stream = new PrintStream(fileOutputStream);
 stream.println("enable1xPrefixes=true");
 stream.close();
 setVariable(serverClassloader, "persistent", Boolean.FALSE);
 startServer(serverFolder.getRoot(), serverClassloader, "live");
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void beforeTest() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 serverFolder.getRoot().mkdirs();
 setVariable(senderClassloader, "persistent", false);
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void setUp() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 evaluate(serverClassloader, "hqfailovertest/hornetqServer.groovy", serverFolder.getRoot().getAbsolutePath());
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void setUp() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 evaluate(serverClassloader, "hqclienttopologytest/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath());
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void beforeTest() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 serverFolder.getRoot().mkdirs();
 setVariable(senderClassloader, "persistent", false);
 startServer(serverFolder.getRoot(), senderClassloader, "1");
}

代码示例来源:origin: apache/activemq-artemis

@Before
public void setUp() throws Throwable {
 FileUtil.deleteDirectory(serverFolder.getRoot());
 setVariable(serverClassloader, "persistent", Boolean.FALSE);
 startServer(serverFolder.getRoot(), serverClassloader, "live");
}

代码示例来源:origin: apache/activemq-artemis

public static ActiveMQServer startServer() throws Exception {
 if (server == null) {
   Configuration config = new ConfigurationImpl().addAcceptorConfiguration("netty", "tcp://localhost:61616").setSecurityEnabled(false).addConnectorConfiguration("netty", "tcp://localhost:61616");
   File dataPlace = new File("./target/dataJoram");
   FileUtil.deleteDirectory(dataPlace);
   config.setJournalDirectory(new File(dataPlace, "./journal").getAbsolutePath()).
    setPagingDirectory(new File(dataPlace, "./paging").getAbsolutePath()).
    setLargeMessagesDirectory(new File(dataPlace, "./largemessages").getAbsolutePath()).
    setBindingsDirectory(new File(dataPlace, "./bindings").getAbsolutePath()).setPersistenceEnabled(true);
   // disable server persistence since JORAM tests do not restart server
   server = ActiveMQServers.newActiveMQServer(config, useFiles);
   // set DLA and expiry to avoid spamming the log with warnings
   server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDeadLetterAddress(SimpleString.toSimpleString("DLA")).setExpiryAddress(SimpleString.toSimpleString("Expiry")));
   server.start();
 }
 return server;
}

相关文章