aQute.lib.osgi.Jar.putResource()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中aQute.lib.osgi.Jar.putResource()方法的一些代码示例,展示了Jar.putResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.putResource()方法的具体详情如下:
包路径:aQute.lib.osgi.Jar
类名称:Jar
方法名:putResource

Jar.putResource介绍

暂无

代码示例

代码示例来源:origin: biz.aQute/bnd

public boolean putResource(String path, Resource resource) {
  return putResource(path, resource, true);
}

代码示例来源:origin: biz.aQute/aQute.bnd

public boolean putResource(String path, Resource resource) {
  return putResource(path, resource, true);
}

代码示例来源:origin: biz.aQute/aQute.bnd

public boolean addDirectory(Map<String, Resource> directory,
    boolean overwrite) {
  boolean duplicates = false;
  if (directory == null)
    return false;
  for (Map.Entry<String, Resource> entry : directory.entrySet()) {
    String key = entry.getKey();
    if (!key.endsWith(".java")) {
      duplicates |= putResource(key, (Resource) entry.getValue(),
          overwrite);
    }
  }
  return duplicates;
}

代码示例来源:origin: biz.aQute/bnd

public boolean addDirectory(Map<String, Resource> directory, boolean overwrite) {
  boolean duplicates = false;
  if (directory == null)
    return false;
  for (Map.Entry<String, Resource> entry : directory.entrySet()) {
    String key = entry.getKey();
    if (!key.endsWith(".java")) {
      duplicates |= putResource(key, (Resource) entry.getValue(), overwrite);
    }
  }
  return duplicates;
}

代码示例来源: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/aQute.bnd

public boolean rename(String oldPath, String newPath) {
  Resource resource = remove(oldPath);
  if (resource == null)
    return false;
  return putResource(newPath, resource);
}

代码示例来源: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 boolean rename(String oldPath, String newPath) {
  Resource resource = remove(oldPath);
  if (resource == null)
    return false;
  return putResource(newPath, resource);
}

代码示例来源:origin: biz.aQute/bnd

public static void build(Jar jar, InputStream in, long lastModified) throws IOException {
  ZipInputStream jin = new ZipInputStream(in);
  ZipEntry entry = jin.getNextEntry();
  while (entry != null) {
    if (!entry.isDirectory()) {
      byte data[] = collect(jin);
      jar.putResource(entry.getName(), new EmbeddedResource(data, lastModified), true);
    }
    entry = jin.getNextEntry();
  }
  jin.close();
}

代码示例来源:origin: biz.aQute/aQute.bnd

public static void build(Jar jar, InputStream in, long lastModified) throws IOException {
  ZipInputStream jin = new ZipInputStream(in);
  ZipEntry entry = jin.getNextEntry();
  while (entry != null) {
    if (!entry.isDirectory()) {
      byte data[] = collect(jin);
      jar.putResource(entry.getName(), new EmbeddedResource(data, lastModified), true);
    }
    entry = jin.getNextEntry();
  }
  jin.close();
}

代码示例来源:origin: biz.aQute/aQute.bnd

static void traverse(Jar jar, int rootlength, File directory,
    Pattern doNotCopy) {
  if (doNotCopy.matcher(directory.getName()).matches())
    return;
  File files[] = directory.listFiles();
  for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory())
      traverse(jar, rootlength, files[i], doNotCopy);
    else {
      String path = files[i].getAbsolutePath().substring(
          rootlength + 1);
      if (File.separatorChar != '/')
        path = path.replace(File.separatorChar, '/');
      jar.putResource(path, new FileResource(files[i]), true);
    }
  }
}

代码示例来源: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/bnd

static void traverse(Jar jar, int rootlength, File directory,
    Pattern doNotCopy) {
  if (doNotCopy != null && doNotCopy.matcher(directory.getName()).matches())
    return;
  jar.updateModified(directory.lastModified(), "Dir change");
  
  File files[] = directory.listFiles();
  for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory())
      traverse(jar, rootlength, files[i], doNotCopy);
    else {
      String path = files[i].getAbsolutePath().substring(
          rootlength + 1);
      if (File.separatorChar != '/')
        path = path.replace(File.separatorChar, '/');
      jar.putResource(path, new FileResource(files[i]), true);
    }
  }
}

代码示例来源: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/bnd

private void createComponentResource(Map<String, Map<String, String>> components,
    String name, Map<String, String> info) throws IOException {
  // We can override the name in the parameters
  if (info.containsKey(COMPONENT_NAME))
    name = info.get(COMPONENT_NAME);
  // Assume the impl==name, but allow override
  String impl = name;
  if (info.containsKey(COMPONENT_IMPLEMENTATION))
    impl = info.get(COMPONENT_IMPLEMENTATION);
  // Check if such a class exists
  analyzer.referTo(impl);
  boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
      || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
  // If we had a designate, we want a default configuration policy of
  // require.
  if (designate && info.get(COMPONENT_CONFIGURATION_POLICY) == null)
    info.put(COMPONENT_CONFIGURATION_POLICY, "require");
  // We have a definition, so make an XML resources
  Resource resource = createComponentResource(name, impl, info);
  analyzer.getJar().putResource("OSGI-INF/" + name + ".xml", resource);
  components.put("OSGI-INF/" + name + ".xml", EMPTY);
}

代码示例来源:origin: biz.aQute/bnd

private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source,
    String destinationPath) throws Exception {
  Jar src = getJarFromName(source, "Include-Resource " + source);
  if (src != null) {
    JarResource jarResource = new JarResource(src);
    jar.putResource(destinationPath, jarResource);
  } else {
    Resource lastChance = make.process(source);
    if (lastChance != null) {
      String x = extra.get("extra");
      if (x != null)
        lastChance.setExtra(x);
      jar.putResource(destinationPath, lastChance);
    } else
      error("Input file does not exist: " + source);
  }
}

代码示例来源:origin: biz.aQute/aQute.bnd

private void noSuchFile(Jar jar, String clause, Map<String, String> extra,
    String source, String destinationPath) throws Exception {
  Jar src = getJarFromName(source, "Include-Resource " + source);
  if (src != null) {
    JarResource jarResource = new JarResource(src);
    jar.putResource(destinationPath, jarResource);
  } else {
    Resource lastChance = make.process(source);
    if (lastChance != null) {
      String x = extra.get("extra");
      if (x != null)
        lastChance.setExtra(x);
      jar.putResource(destinationPath, lastChance);
    } else
      error("Input file does not exist: " + source);
  }
}

代码示例来源:origin: biz.aQute/bnd

void applyPatch(String old, String patch, String newer) throws Exception {
  Jar a = new Jar(new File(old));
  Jar b = new Jar(new File(patch));
  Manifest bm = b.getManifest();
  String patchDelete = bm.getMainAttributes().getValue("Patch-Delete");
  String patchVersion = bm.getMainAttributes().getValue("Patch-Version");
  if (patchVersion == null) {
    error("To patch, you must provide a patch bundle.\nThe given " + patch
        + " bundle does not contain the Patch-Version header");
    return;
  }
  Collection<String> delete = split(patchDelete);
  Set<String> paths = new HashSet<String>(a.getResources().keySet());
  paths.removeAll(delete);
  for (String path : paths) {
    Resource br = b.getResource(path);
    if (br == null)
      b.putResource(path, a.getResource(path));
  }
  bm.getMainAttributes().putValue("Bundle-Version", patchVersion);
  b.write(new File(newer));
  a.close();
  b.close();
}

代码示例来源:origin: biz.aQute/bnd

public boolean analyzeJar(Analyzer analyzer) throws Exception {

    Map<String, Map<String, String>> map = analyzer.parseHeader(analyzer
        .getProperty(Constants.METATYPE));

    Jar jar = analyzer.getJar();
    for (String name : map.keySet()) {
      Collection<Clazz> metatypes = analyzer.getClasses("", QUERY.ANNOTATION.toString(),
          Meta.OCD.class.getName(), // 
          QUERY.NAMED.toString(), name //
          );
      for (Clazz c : metatypes) {
        jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c,
            analyzer));
      }
    }
    return false;
  }
}

代码示例来源: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;
}

相关文章