-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0987e2
commit 80b8972
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ute.repository/src/aQute/bnd/deployer/repository/providers/KnownBundleAnalyzerPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package aQute.bnd.deployer.repository.providers; | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
import org.osgi.service.indexer.*; | ||
import org.osgi.service.indexer.impl.*; | ||
|
||
import aQute.bnd.service.*; | ||
import aQute.service.reporter.*; | ||
|
||
public class KnownBundleAnalyzerPlugin extends KnownBundleAnalyzer implements ResourceAnalyzer, Plugin { | ||
|
||
private static final String PROP_DATA = "data"; | ||
|
||
private Reporter reporter; | ||
|
||
public KnownBundleAnalyzerPlugin() { | ||
super(new Properties()); | ||
} | ||
|
||
public void setProperties(Map<String,String> config) { | ||
String fileName = config.get(PROP_DATA); | ||
if (fileName == null) | ||
throw new IllegalArgumentException(String.format("Property name '%s' must be set on KnownBundleAnalyzerPlugin", PROP_DATA)); | ||
File file = new File(fileName); | ||
if (!file.isFile()) | ||
throw new IllegalArgumentException(String.format("Data file does not exist, or is not a plain file: %s", file)); | ||
|
||
FileInputStream stream = null; | ||
try { | ||
stream = new FileInputStream(file); | ||
Properties props = new Properties(); | ||
props.load(stream); | ||
setKnownBundlesExtra(props); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException(String.format("Unable to read data file: %s", file), e); | ||
} finally { | ||
try { if (stream != null) stream.close(); } catch (IOException e) {} | ||
} | ||
} | ||
|
||
public void setReporter(Reporter reporter) { | ||
this.reporter = reporter; | ||
} | ||
|
||
} |