本文整理了Java中aQute.lib.osgi.Jar.getResources()
方法的一些代码示例,展示了Jar.getResources()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.getResources()
方法的具体详情如下:
包路径:aQute.lib.osgi.Jar
类名称:Jar
方法名:getResources
暂无
代码示例来源:origin: biz.aQute/bnd
private void copyInfoResource(Jar source, Jar dest, String type) {
if ( source.getResources().containsKey(type) && !dest.getResources().containsKey(type))
dest.putResource(type, source.getResource(type));
}
代码示例来源:origin: biz.aQute/aQute.bnd
private void statistics(Jar jar, File output, String msg) {
out.println(jar.getName() + " " + jar.getResources().size() + " "
+ output.length() + msg);
}
代码示例来源:origin: biz.aQute/bnd
private void statistics(Jar jar, File output, String msg) {
out.println(jar.getName() + " " + jar.getResources().size() + " " + output.length() + msg);
}
代码示例来源:origin: biz.aQute/bnd
private void split(Jar original, Jar main, Jar src) {
for (Map.Entry<String, Resource> e : original.getResources().entrySet()) {
String path = e.getKey();
if (path.startsWith("OSGI-OPT/src/")) {
src.putResource(path.substring("OSGI-OPT/src/".length()), e.getValue());
} else {
main.putResource(path, e.getValue());
}
}
}
代码示例来源:origin: biz.aQute/bnd
private void split(Jar original, Jar main, Jar src) {
for (Map.Entry<String, Resource> e : original.getResources().entrySet()) {
String path = e.getKey();
if (path.startsWith("OSGI-OPT/src/")) {
src.putResource(path.substring("OSGI-OPT/src/".length()), e.getValue());
} else {
main.putResource(path, e.getValue());
}
}
}
代码示例来源:origin: biz.aQute/bnd
public void add( Jar jar ) throws Exception {
for ( Resource r : jar.getResources().values()) {
InputStream in = r.openInputStream();
try {
parse(in);
} finally {
in.close();
}
}
}
代码示例来源:origin: biz.aQute/bnd
private void doManifest(Jar jar, String[] digestNames,
MessageDigest[] algorithms, OutputStream out) throws Exception {
for (Map.Entry<String,Resource> entry : jar.getResources().entrySet()) {
String name = entry.getKey();
if (!METAINFDIR.matcher(name).matches()) {
out.write("\r\n".getBytes());
out.write("Name: ".getBytes());
out.write(name.getBytes());
out.write("\r\n".getBytes());
digest(algorithms, entry.getValue());
for (int a = 0; a < algorithms.length; a++) {
if (algorithms[a] != null) {
byte[] digest = algorithms[a].digest();
String header = digestNames[a] + "-Digest: "
+ new Base64(digest) + "\r\n";
out.write(header.getBytes());
}
}
}
}
}
代码示例来源:origin: biz.aQute/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 : 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/aQute.bnd
/**
* Add all the resources in the given jar that match the given filter.
*
* @param sub
* the jar
* @param filter
* a pattern that should match the resoures in sub to be added
*/
public boolean addAll(Jar sub, Pattern filter) {
boolean dupl = false;
for (String name : sub.getResources().keySet()) {
if ("META-INF/MANIFEST.MF".equals(name))
continue;
if (filter == null || filter.matcher(name).matches())
dupl |= putResource(name, sub.getResource(name), true);
}
return dupl;
}
代码示例来源:origin: biz.aQute/aQute.bnd
private void reportNewer(long lastModified, Jar jar) {
if (isTrue(getProperty(Constants.REPORTNEWER))) {
StringBuilder sb = new StringBuilder();
String del = "Newer than " + new Date(lastModified);
for (Map.Entry<String, Resource> entry : jar.getResources()
.entrySet()) {
if (entry.getValue().lastModified() > lastModified) {
sb.append(del);
del = ", \n ";
sb.append(entry.getKey());
}
}
if (sb.length() > 0)
warning(sb.toString());
}
}
代码示例来源:origin: biz.aQute/bnd
private void reportNewer(long lastModified, Jar jar) {
if (isTrue(getProperty(Constants.REPORTNEWER))) {
StringBuilder sb = new StringBuilder();
String del = "Newer than " + new Date(lastModified);
for (Map.Entry<String, Resource> entry : jar.getResources().entrySet()) {
if (entry.getValue().lastModified() > lastModified) {
sb.append(del);
del = ", \n ";
sb.append(entry.getKey());
}
}
if (sb.length() > 0)
warning(sb.toString());
}
}
代码示例来源:origin: biz.aQute/aQute.bnd
public void addClasspath(Jar jar) {
if (isPedantic() && jar.getResources().isEmpty())
warning("There is an empty jar or directory on the classpath: "
+ jar.getName());
classpath.add(jar);
}
代码示例来源:origin: biz.aQute/bnd
/**
* Expand the JAR file to a directory.
*
* @param dir
* the dst directory, is not required to exist
* @throws Exception
* if anything does not work as expected.
*/
public void expand(File dir) throws Exception {
dir = dir.getAbsoluteFile();
dir.mkdirs();
if (!dir.isDirectory()) {
throw new IllegalArgumentException("Not a dir: " + dir.getAbsolutePath());
}
for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
File f = getFile(dir, entry.getKey());
f.getParentFile().mkdirs();
copy(entry.getValue().openInputStream(), f);
}
}
代码示例来源:origin: biz.aQute/bnd
public void addClasspath(Jar jar) {
if (isPedantic() && jar.getResources().isEmpty())
warning("There is an empty jar or directory on the classpath: " + jar.getName());
classpath.add(jar);
}
代码示例来源:origin: biz.aQute/aQute.bnd
public void write(OutputStream out) throws IOException {
ZipOutputStream jout = nomanifest ? new ZipOutputStream(out) : new JarOutputStream(out);
Set<String> done = new HashSet<String>();
Set<String> directories = new HashSet<String>();
if (doNotTouchManifest) {
writeResource(jout, directories, "META-INF/MANIFEST.MF",
getResource("META-INF/MANIFEST.MF"));
done.add("META-INF/MANIFEST.MF");
} else if (!nomanifest)
doManifest(done, jout);
for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
// Skip metainf contents
if (!done.contains(entry.getKey()))
writeResource(jout, directories, (String) entry.getKey(),
(Resource) entry.getValue());
}
jout.finish();
}
代码示例来源:origin: biz.aQute/bnd
public void write(OutputStream out) throws Exception {
ZipOutputStream jout = nomanifest || doNotTouchManifest ? new ZipOutputStream(out)
: new JarOutputStream(out);
Set<String> done = new HashSet<String>();
Set<String> directories = new HashSet<String>();
if (doNotTouchManifest) {
Resource r = getResource("META-INF/MANIFEST.MF");
if (r != null) {
writeResource(jout, directories, "META-INF/MANIFEST.MF", r);
done.add("META-INF/MANIFEST.MF");
}
} else
doManifest(done, jout);
for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
// Skip metainf contents
if (!done.contains(entry.getKey()))
writeResource(jout, directories, (String) entry.getKey(),
(Resource) entry.getValue());
}
jout.finish();
}
代码示例来源: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
public File saveBuild(Jar jar) throws Exception {
try {
String bsn = jar.getName();
File f = getOutputFile(bsn);
String msg = "";
if (!f.exists() || f.lastModified() < jar.lastModified()) {
reportNewer(f.lastModified(), jar);
f.delete();
if (!f.getParentFile().isDirectory())
f.getParentFile().mkdirs();
jar.write(f);
getWorkspace().changedFile(f);
} else {
msg = "(not modified since " + new Date(f.lastModified()) + ")";
}
trace(jar.getName() + " (" + f.getName() + ") " + jar.getResources().size() + " " + msg);
return f;
} finally {
jar.close();
}
}
代码示例来源:origin: biz.aQute/bnd
/**
* Add all the resources in the given jar that match the given filter.
*
* @param sub
* the jar
* @param filter
* a pattern that should match the resoures in sub to be added
*/
public boolean addAll(Jar sub, Instruction filter, String destination) {
boolean dupl = false;
for (String name : sub.getResources().keySet()) {
if ("META-INF/MANIFEST.MF".equals(name))
continue;
if (filter == null || filter.matches(name) != filter.isNegated())
dupl |= putResource(Processor.appendPath(destination, name), sub.getResource(name),
true);
}
return dupl;
}
代码示例来源:origin: org.fusesource.fabric.fab/fab-osgi
/**
* Returns the {@link Jar} if exists and is valid or creates on from scratch.
* @return the {@link Jar} that corresponds to the object properties.
* @throws Exception
*/
private Jar getOrCreateJar() throws Exception {
if (this.jar != null && jar.getResources() != null) {
return jar;
} else {
return BndUtils.createJar(
URLUtils.prepareInputStream(new URL(fabUri), configuration.getCertificateCheck()),
instructions,
fabUri,
OverwriteMode.MERGE,
embeddedResources,
classPathResolver.getExtraImportPackages(),
actualImports,
this);
}
}
内容来源于网络,如有侵权,请联系作者删除!