Posts

Showing posts from May, 2015

When to use Import-Package and Require-Bundle in Eclipse Plugin?

The OSGi way is to use Import-Package, as it specifically decouples the package from the bundle that provides it. Require-Bundle: Bundles can be re-exported Gives you access to all exports of the bundle, regardless of what they are, and regardless of whether you need them. Specifies the explicit bundle (and version) to use. If a required bundle needs to be refactored and a package moved elsewhere, then dependents will need changes to their MANIFEST.MF file. Import-Package: Loose coupling, only the package (and version) is specified and the run-time finds the required bundle. Actual implementations can be swapped out Dependent packages can be moved to different bundles by the package owner But requires more metadata to be maintained (i.e: each package name) at lower levels of granularity In my view we should below approach in using Import Package or Require-Bundle Interface <=> Import-Package Implementation class <=>

Creating password protected ZIP file using TrueZip

try { final TConfig config = TConfig.get(); // Request encryption in archive files. config.setOutputPreferences(config.getOutputPreferences() .or(BitField.of(FsOutputOption.ENCRYPT))); // Configure archive detector with custom key management for ZIP files. config.setArchiveDetector(newArchiveDetector1("zip", "password")); // Setup file paths. TFile src = new TFile("file1"); TFile dst = new TFile("file2"); if (dst.isArchive() || dst.isDirectory()) dst = new TFile(dst, src.getName()); // Recursive copy. src.cp_rp(dst); } finally { // Commit changes. TVFS.umount(); }