本文整理了Java中aQute.lib.osgi.Jar.getDirectories()
方法的一些代码示例,展示了Jar.getDirectories()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.getDirectories()
方法的具体详情如下:
包路径:aQute.lib.osgi.Jar
类名称:Jar
方法名:getDirectories
暂无
代码示例来源:origin: biz.aQute/bnd
/**
* Analyze the classpath for a split package
*
* @param pack
* @param classpath
* @param source
* @return
*/
private String diagnostic(String pack, List<Jar> classpath, File source) {
// Default is like merge-first, but with a warning
// Find the culprits
pack = pack.replace('.', '/');
List<Jar> culprits = new ArrayList<Jar>();
for (Iterator<Jar> i = classpath.iterator(); i.hasNext();) {
Jar culprit = (Jar) i.next();
if (culprit.getDirectories().containsKey(pack)) {
culprits.add(culprit);
}
}
return "Split package "
+ pack
+ "\nUse directive -split-package:=(merge-first|merge-last|error|first) on Export/Private Package instruction to get rid of this warning\n"
+ "Package found in " + culprits + "\n" + "Reference from " + source + "\n"
+ "Classpath " + classpath;
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
* Analyze the classpath for a split package
*
* @param pack
* @param classpath
* @param source
* @return
*/
private String diagnostic(String pack, List<Jar> classpath, File source) {
// Default is like merge-first, but with a warning
// Find the culprits
pack = pack.replace('.', '/');
List<Jar> culprits = new ArrayList<Jar>();
for (Iterator<Jar> i = classpath.iterator(); i.hasNext();) {
Jar culprit = (Jar) i.next();
if (culprit.getDirectories().containsKey(pack)) {
culprits.add(culprit);
}
}
return "Split package "
+ pack
+ "\nUse directive -split-package:=(merge-first|merge-last|error|first) on Export/Private Package instruction to get rid of this warning\n"
+ "Package found in " + culprits + "\n"
+ "Reference from " + source + "\n" + "Classpath "
+ classpath;
}
代码示例来源:origin: biz.aQute/bnd
/**
* Calculate an export header solely based on the contents of a JAR file
*
* @param bundle
* The jar file to analyze
* @return
*/
public String calculateExportsFromContents(Jar bundle) {
String ddel = "";
StringBuffer sb = new StringBuffer();
Map<String, Map<String, Resource>> map = bundle.getDirectories();
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String directory = (String) i.next();
if (directory.equals("META-INF") || directory.startsWith("META-INF/"))
continue;
if (directory.equals("OSGI-OPT") || directory.startsWith("OSGI-OPT/"))
continue;
if (directory.equals("/"))
continue;
if (directory.endsWith("/"))
directory = directory.substring(0, directory.length() - 1);
directory = directory.replace('/', '.');
sb.append(ddel);
sb.append(directory);
ddel = ",";
}
return sb.toString();
}
代码示例来源:origin: biz.aQute/bnd
/**
* Get the exporter of a package ...
*/
public String _exporters(String args[]) throws Exception {
Macro.verifyCommand(
args,
"${exporters;<packagename>}, returns the list of jars that export the given package",
null, 2, 2);
StringBuilder sb = new StringBuilder();
String del = "";
String pack = args[1].replace('.', '/');
for (Jar jar : classpath) {
if (jar.getDirectories().containsKey(pack)) {
sb.append(del);
sb.append(jar.getName());
}
}
return sb.toString();
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
* Calculate an export header solely based on the contents of a JAR file
*
* @param bundle
* The jar file to analyze
* @return
*/
public String calculateExportsFromContents(Jar bundle) {
String ddel = "";
StringBuffer sb = new StringBuffer();
Map<String, Map<String, Resource>> map = bundle.getDirectories();
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String directory = (String) i.next();
if (directory.equals("META-INF")
|| directory.startsWith("META-INF/"))
continue;
if (directory.equals("OSGI-OPT")
|| directory.startsWith("OSGI-OPT/"))
continue;
if (directory.equals("/"))
continue;
if (directory.endsWith("/"))
directory = directory.substring(0, directory.length() - 1);
directory = directory.replace('/', '.');
sb.append(ddel);
sb.append(directory);
ddel = ",";
}
return sb.toString();
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
* Get the exporter of a package ...
*/
public String _exporters(String args[]) throws Exception {
Macro
.verifyCommand(
args,
"${exporters;<packagename>}, returns the list of jars that export the given package",
null, 2, 2);
StringBuilder sb = new StringBuilder();
String del = "";
String pack = args[1].replace('.', '/');
for (Jar jar : classpath) {
if (jar.getDirectories().containsKey(pack)) {
sb.append(del);
sb.append(jar.getName());
}
}
return sb.toString();
}
代码示例来源:origin: biz.aQute/bnd
public boolean analyzeJar(Analyzer analyzer) throws Exception {
Jar jar = analyzer.getJar();
Map<String,Resource> dir = jar.getDirectories().get(root);
if (dir == null || dir.isEmpty()) {
Resource resource = jar.getResource(root);
if ( resource != null )
process(analyzer, root, resource);
return false;
}
for (Iterator<Map.Entry<String,Resource>> i = dir.entrySet().iterator(); i.hasNext();) {
Map.Entry<String,Resource> entry = i.next();
String path = entry.getKey();
Resource resource = entry.getValue();
if (paths.matcher(path).matches()) {
process(analyzer, path, resource);
}
}
return false;
}
代码示例来源:origin: biz.aQute/bnd
/**
* Print the metatypes in this JAR.
*
* @param jar
*/
private void printMetatype(PrintStream out, Jar jar) throws Exception {
out.println("[METATYPE]");
Manifest manifest = jar.getManifest();
if (manifest == null) {
out.println("No manifest");
return;
}
Map<String, Resource> map = jar.getDirectories().get("OSGI-INF/metatype");
if (map != null) {
for (Map.Entry<String, Resource> entry : map.entrySet()) {
out.println(entry.getKey());
IO.copy(entry.getValue().openInputStream(), out);
out.println();
}
out.println();
}
}
代码示例来源:origin: biz.aQute/bnd
public void verifyBundleClasspath() {
Map<String, Map<String, String>> bcp = parseHeader(getHeader(Analyzer.BUNDLE_CLASSPATH));
if (bcp.isEmpty() || bcp.containsKey("."))
return;
for ( String path : bcp.keySet() ) {
if ( path.endsWith("/"))
error("A Bundle-ClassPath entry must not end with '/': %s", path);
if ( dot.getDirectories().containsKey(path))
// We assume that any classes are in a directory
// and therefore do not care when the bundle is included
return;
}
for (String path : dot.getResources().keySet()) {
if (path.endsWith(".class")) {
warning("The Bundle-Classpath does not contain the actual bundle JAR (as specified with '.' in the Bundle-Classpath) but the JAR does contain classes. Is this intentional?");
return;
}
}
}
代码示例来源:origin: biz.aQute/bnd
@SuppressWarnings("unchecked")
public boolean analyzeJar(Analyzer analyzer) throws Exception {
Jar jar = analyzer.getJar();
Map dir = (Map) jar.getDirectories().get("META-INF/spring");
if ( dir == null || dir.isEmpty())
return false;
for (Iterator i = dir.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String path = (String) entry.getKey();
Resource resource = (Resource) entry.getValue();
if (SPRING_SOURCE.matcher(path).matches()) {
try {
InputStream in = resource.openInputStream();
Set set = analyze(in);
in.close();
for (Iterator r = set.iterator(); r.hasNext();) {
String pack = (String) r.next();
if ( !QN.matcher(pack).matches())
analyzer.warning("Package does not seem a package in spring resource ("+path+"): " + pack );
if (!analyzer.getReferred().containsKey(pack))
analyzer.getReferred().put(pack, new LinkedHashMap());
}
} catch( Exception e ) {
analyzer.error("Unexpected exception in processing spring resources("+path+"): " + e );
}
}
}
return false;
}
代码示例来源:origin: biz.aQute/bnd
.getAbsolutePath());
out.printf("Name : %s\n", jar.getName());
Map<String, Map<String, Resource>> dirs = jar.getDirectories();
for (Map.Entry<String, Map<String, Resource>> entry : dirs.entrySet()) {
Map<String, Resource> dir = entry.getValue();
代码示例来源:origin: biz.aQute/aQute.bnd
size = dot.getDirectories().size();
analyze();
analyzed = false;
doExpand(dot, CONDITIONAL_PACKAGE + " Private imports",
replaceWitInstruction(filtered, CONDITIONAL_PACKAGE), false);
} while (dot.getDirectories().size() > size);
analyzed = true;
代码示例来源:origin: biz.aQute/aQute.bnd
builder.addClose(signed);
Map<String, Resource> dir = signed.getDirectories().get("META-INF");
for (String path : dir.keySet()) {
if (path.matches(".*\\.(DSA|RSA|SF|MF)$")) {
代码示例来源:origin: biz.aQute/bnd
/**
* Create the imports/exports by parsing
*
* @throws IOException
*/
void analyzeClasspath() throws Exception {
classpathExports = newHashMap();
for (Iterator<Jar> c = getClasspath().iterator(); c.hasNext();) {
Jar current = c.next();
checkManifest(current);
for (Iterator<String> j = current.getDirectories().keySet().iterator(); j.hasNext();) {
String dir = j.next();
Resource resource = current.getResource(dir + "/packageinfo");
if (resource != null) {
InputStream in = resource.openInputStream();
try {
String version = parsePackageInfo(in);
setPackageInfo(dir, VERSION_ATTRIBUTE, version);
} finally {
in.close();
}
}
}
}
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
* Create the imports/exports by parsing
*
* @throws IOException
*/
void analyzeClasspath() throws IOException {
classpathExports = newHashMap();
for (Iterator<Jar> c = getClasspath().iterator(); c.hasNext();) {
Jar current = c.next();
checkManifest(current);
for (Iterator<String> j = current.getDirectories().keySet()
.iterator(); j.hasNext();) {
String dir = j.next();
Resource resource = current.getResource(dir + "/packageinfo");
if (resource != null) {
InputStream in = resource.openInputStream();
try {
String version = parsePackageInfo(in);
setPackageInfo(dir, "version", version);
} finally {
in.close();
}
}
}
}
}
代码示例来源:origin: biz.aQute/bnd
+ jarOrDir + ", " + e);
} else if (dot.getDirectories().containsKey(jarOrDir)) {
if (r3)
error("R3 bundles do not support directories on the Bundle-ClassPath: "
代码示例来源:origin: biz.aQute/bnd
if (dot.getDirectories().containsKey(path)) {
containsDirectory = true;
break;
if (dot.getDirectories().containsKey(path)) {
代码示例来源:origin: biz.aQute/aQute.bnd
+ jarOrDir + ", " + e);
} else if (dot.getDirectories().containsKey(jarOrDir)) {
if (r3)
error("R3 bundles do not support directories on the Bundle-ClassPath: "
代码示例来源:origin: biz.aQute/aQute.bnd
if (dot.getDirectories().containsKey(path)) {
analyzeJar(dot, path + '/', classSpace, contained,
referred, uses);
代码示例来源:origin: biz.aQute/bnd
builder.addClose(signed);
Map<String, Resource> dir = signed.getDirectories().get("META-INF");
for (String path : dir.keySet()) {
if (path.matches(".*\\.(DSA|RSA|SF|MF)$")) {
内容来源于网络,如有侵权,请联系作者删除!