org.pf4j.util.FileUtils Java Examples

The following examples show how to use org.pf4j.util.FileUtils. 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 File: PluginIntegrationTest.java    From sbp with 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 File: NativeLibPluginClassLoader.java    From dremio-oss with 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 File: CustomPluginLoader.java    From sbp with 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 File: LiiklusPluginLoader.java    From liiklus with MIT License 4 votes vote down vote up
@Override
public boolean isApplicable(Path pluginPath) {
    return Files.exists(pluginPath) && FileUtils.isJarFile(pluginPath);
}