@Test public void testGetPlanClassPath() { Result<OpearFile> opearResult = OpearFile.fromDirectory( new File("src/test/resources/OpearFileTest/folders_on_classpath")); assertFalse("opearResult should not be a failure", opearResult.isFailure()); OpearFile opearFile = opearResult.getOrDefault(null); assertNotNull("opearFile is not null", opearFile); assertArrayEquals("classpath should be", new String[]{"classes", "test-classes"}, opearFile.metadata.getPlanClassPath()); }
public static Result<OpearFile> fromDirectory(final @NotNull File directory) { return Result.success(Optional.of(new File(directory, JarFile.MANIFEST_NAME))) .flatMap(oMfFile -> oMfFile .filter(File::exists) .map(OpearFile::readExpectedManifest) .map(manResult -> manResult.flatMap(OpearFile::validateOpearManifest)) .orElseGet(() -> Result.success(metaForSimpleDir(directory))) ) .map(meta -> new OpearFile(directory, meta)); }
OpearFile implements Opear { public static Result<OpearFile> fromDirectory(final @NotNull File directory) { return Result.success(Optional.of(new File(directory, JarFile.MANIFEST_NAME))) .flatMap(oMfFile -> oMfFile .filter(File::exists) .map(OpearFile::readExpectedManifest) .map(manResult -> manResult.flatMap(OpearFile::validateOpearManifest)) .orElseGet(() -> Result.success(metaForSimpleDir(directory))) ) .map(meta -> new OpearFile(directory, meta)); } }
OpearFile implements Opear { public static Result<OpearFile> fromDirectory(final @NotNull File directory) { return Result.success(Optional.of(new File(directory, JarFile.MANIFEST_NAME))) .flatMap(oMfFile -> oMfFile .filter(File::exists) .map(OpearFile::readExpectedManifest) .map(manResult -> manResult.flatMap(OpearFile::validateOpearManifest)) .orElseGet(() -> Result.success(metaForSimpleDir(directory))) ) .map(meta -> new OpearFile(directory, meta)); } OpearFile(final File cacheDir, final OpearMetadata metadata); }
OpearFile implements Opear { public static Result<OpearFile> fromDirectory(final @NotNull File directory) { return Result.success(Optional.of(new File(directory, JarFile.MANIFEST_NAME))) .flatMap(oMfFile -> oMfFile .filter(File::exists) .map(OpearFile::readExpectedManifest) .map(manResult -> manResult.flatMap(OpearFile::validateOpearManifest)) .orElseGet(() -> Result.success(metaForSimpleDir(directory))) ) .map(meta -> new OpearFile(directory, meta)); } OpearFile(final File cacheDir, final OpearMetadata metadata); @Override URL getDefaultPlan(); @Override Result<URL> getSpecificPlan(final @NotNull String planName); @Override ClassLoader getPlanClassLoader(final @NotNull ClassLoader parent); static Result<OpearFile> fromDirectory(final @NotNull File directory); static Result<OpearFile> fromJar(final @NotNull JarFile jarFile, final @NotNull File cacheBaseDir); }
OpearFile implements Opear { public static Result<OpearFile> fromDirectory(final @NotNull File directory) { return Result.success(Optional.of(new File(directory, JarFile.MANIFEST_NAME))) .flatMap(oMfFile -> oMfFile .filter(File::exists) .map(OpearFile::readExpectedManifest) .map(manResult -> manResult.flatMap(OpearFile::validateOpearManifest)) .orElseGet(() -> Result.success(metaForSimpleDir(directory))) ) .map(meta -> new OpearFile(directory, meta)); } OpearFile(final File cacheDir, final OpearMetadata metadata); @Override URL getDefaultPlan(); @Override Result<URL> getSpecificPlan(final @NotNull String planName); @Override ClassLoader getPlanClassLoader(final @NotNull ClassLoader parent); static Result<OpearFile> fromDirectory(final @NotNull File directory); static Result<OpearFile> fromJar(final @NotNull JarFile jarFile, final @NotNull File cacheBaseDir); static final Attributes.Name NAME_BUNDLE_SYMBOLICNAME; static final Attributes.Name NAME_BUNDLE_VERSION; static final Attributes.Name NAME_CLASS_PATH; static final Attributes.Name NAME_OAKPAL_VERSION; static final Attributes.Name NAME_OAKPAL_PLAN; }