Java Code Examples for org.pf4j.util.FileUtils

The following examples show how to use org.pf4j.util.FileUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: sbp   Source File: PluginIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void loadResourceFromPluginFirst() throws IOException {
    // resource should be loaded from plugin first
    // class should be loaded from app and parent plugin first
    SpringBootPlugin authorPlugin = (SpringBootPlugin)
            pluginManager.getPlugin("demo-plugin-author").getPlugin();
    assertThat(authorPlugin, notNullValue());

    SpringBootPlugin shelfPlugin = (SpringBootPlugin)
            pluginManager.getPlugin("demo-plugin-shelf").getPlugin();
    assertThat(shelfPlugin, notNullValue());

    URL authorRes = authorPlugin.getWrapper().getPluginClassLoader().getResource("res.txt");
    assertThat(authorRes, notNullValue());
    assertThat(authorRes.getPath(), stringContainsInOrder(Arrays.asList("plugins", "demo-plugin-author")));
    List<String> contents = FileUtils.readLines(Path.of(authorRes.getPath()), true);
    assertThat(contents, hasItem("author"));

    URL shelfRes = shelfPlugin.getWrapper().getPluginClassLoader().getResource("res.txt");
    assertThat(shelfRes, notNullValue());
    contents = FileUtils.readLines(Path.of(shelfRes.getPath()), true);
    assertThat(contents, hasItem("app"));
}
 
Example 2
Source Project: dremio-oss   Source File: NativeLibPluginClassLoader.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void close() throws IOException {
  try {
    synchronized (this) {
      if (tempDirectory != null) {
        // This method recursively deletes the directory tree passed in.
        FileUtils.delete(tempDirectory);
        tempDirectory = null;
      }
    }
  } catch (IOException ex) {
    logger.error("Error deleting temporary directory for native libraries {}", tempDirectory, ex);
  }

  super.close();
}
 
Example 3
Source Project: sbp   Source File: CustomPluginLoader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isApplicable(Path pluginPath) {
    return Files.exists(pluginPath) && FileUtils.isJarFile(pluginPath);
}
 
Example 4
Source Project: liiklus   Source File: LiiklusPluginLoader.java    License: MIT License 4 votes vote down vote up
@Override
public boolean isApplicable(Path pluginPath) {
    return Files.exists(pluginPath) && FileUtils.isJarFile(pluginPath);
}