• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Jar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中aQute.bnd.osgi.Jar的典型用法代码示例。如果您正苦于以下问题:Java Jar类的具体用法?Java Jar怎么用?Java Jar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Jar类属于aQute.bnd.osgi包,在下文中一共展示了Jar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doWabStaging

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private void doWabStaging(Analyzer analyzer) throws Exception {
    if (!isWab()) {
        return;
    }
    String wab = analyzer.getProperty(analyzer.WAB);
    Jar dot = analyzer.getJar();

    log("wab %s", wab);
    analyzer.setBundleClasspath("WEB-INF/classes," +
                                analyzer.getProperty(analyzer.BUNDLE_CLASSPATH));

    Set<String> paths = new HashSet<String>(dot.getResources().keySet());

    for (String path : paths) {
        if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
            log("wab: moving: %s", path);
            dot.rename(path, "WEB-INF/classes/" + path);
        }
    }

    Path wabRoot = Paths.get(wab);
    includeFiles(dot, null, wabRoot.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OSGiWrapper.java


示例2: doIncludeResources

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
/**
 * Parse the Bundle-Includes header. Files in the bundles Include header are
 * included in the jar. The source can be a directory or a file.
 *
 * @throws Exception
 */
private void doIncludeResources(Analyzer analyzer) throws Exception {
    String includes = analyzer.getProperty(Analyzer.INCLUDE_RESOURCE);
    if (includes == null) {
        return;
    }
    Parameters clauses = analyzer.parseHeader(includes);
    Jar jar = analyzer.getJar();

    for (Map.Entry<String, Attrs> entry : clauses.entrySet()) {
        String name = entry.getKey();
        Map<String, String> extra = entry.getValue();
        // TODO consider doing something with extras

        String[] parts = name.split("\\s*=\\s*");
        String source = parts[0];
        String destination = parts[0];
        if (parts.length == 2) {
            source = parts[1];
        }

        includeFiles(jar, destination, source);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:OSGiWrapper.java


示例3: addFileToJar

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private boolean addFileToJar(Jar jar, String destination, String sourceAbsPath) {
    if (includedResources.contains(sourceAbsPath)) {
        log("Skipping already included resource: %s\n", sourceAbsPath);
        return false;
    }
    File file = new File(sourceAbsPath);
    if (!file.isFile()) {
        throw new RuntimeException(
                String.format("Skipping non-existent file: %s\n", sourceAbsPath));
    }
    Resource resource = new FileResource(file);
    if (jar.getResource(destination) != null) {
        warn("Skipping duplicate resource: %s\n", destination);
        return false;
    }
    jar.putResource(destination, resource);
    includedResources.add(sourceAbsPath);
    log("Adding resource: %s\n", destination);
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:OSGiWrapper.java


示例4: getAuxiliaryArchivesPackages

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private List<String> getAuxiliaryArchivesPackages(
		Collection<Archive<?>> auxiliaryArchives)
	throws IOException {

	List<String> packages = new ArrayList<>();

	for (Archive auxiliaryArchive : auxiliaryArchives) {
		ZipExporter zipExporter = auxiliaryArchive.as(ZipExporter.class);

		InputStream auxiliaryArchiveInputStream =
			zipExporter.exportAsInputStream();

		Jar jar = new Jar(
			auxiliaryArchive.getName(), auxiliaryArchiveInputStream);

		packages.addAll(jar.getPackages());
	}

	return packages;
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:21,代码来源:ImportPackageManagerImpl.java


示例5: tree

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
@Override
public Tree tree(Jar jar) throws Exception {
	Tree result = null;
	if (jar.getSource() != null && jar.getSource().isFile()) {
		HashCode newCode = Files.hash(jar.getSource(), hashFunction);
		result = cachedTrees.get(newCode);
		if (result == null) {
			result = delegate.tree(jar);
		}
		cachedTrees.put(newCode, result);
	}
	if (result == null) {
		result = delegate.tree(jar);
	}
	return result;
}
 
开发者ID:cbrun,项目名称:baseliner,代码行数:17,代码来源:CachedDiffer.java


示例6: doWabStaging

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private void doWabStaging(Analyzer analyzer) throws Exception {
    if (!isWab()) {
        return;
    }
    String wab = analyzer.getProperty(analyzer.WAB);
    Jar dot = analyzer.getJar();

    log("wab %s", wab);
    analyzer.setBundleClasspath("WEB-INF/classes," +
                                analyzer.getProperty(analyzer.BUNDLE_CLASSPATH));

    Set<String> paths = new HashSet<>(dot.getResources().keySet());

    for (String path : paths) {
        if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
            log("wab: moving: %s", path);
            dot.rename(path, "WEB-INF/classes/" + path);
        }
    }

    Path wabRoot = Paths.get(wab);
    includeFiles(dot, null, wabRoot.toString());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:OSGiWrapper.java


示例7: doWabStaging

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private void doWabStaging(Analyzer analyzer) throws Exception {
    if (!isWab()) {
        return;
    }
    String wab = analyzer.getProperty(analyzer.WAB);
    Jar dot = analyzer.getJar();

    log("wab %s", wab);
    analyzer.setBundleClasspath("WEB-INF/classes," +
                                        analyzer.getProperty(analyzer.BUNDLE_CLASSPATH));

    Set<String> paths = new HashSet<>(dot.getResources().keySet());

    for (String path : paths) {
        if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
            log("wab: moving: %s", path);
            dot.rename(path, "WEB-INF/classes/" + path);
        }
    }

    Path wabRoot = Paths.get(wab);
    includeFiles(dot, null, wabRoot.toString());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:OSGiWrapper.java


示例8: includeFiles

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private void includeFiles(Jar jar, String destinationRoot, String sourceRoot)
        throws IOException {

    Path classesBasedPath = classesDir.resolve(sourceRoot);
    Path sourceBasedPath = sourcesDir.resolve(sourceRoot);

    File classFile = classesBasedPath.toFile();
    File sourceFile = sourceBasedPath.toFile();

    if (classFile.isFile()) {
        addFileToJar(jar, destinationRoot, classesBasedPath.toAbsolutePath().toString());
    } else if (sourceFile.isFile()) {
        addFileToJar(jar, destinationRoot, sourceBasedPath.toAbsolutePath().toString());
    } else if (classFile.isDirectory()) {
        includeDirectory(jar, destinationRoot, classesBasedPath);
    } else if (sourceFile.isDirectory()) {
        includeDirectory(jar, destinationRoot, sourceBasedPath);
    } else {
        warn("Skipping resource in bundle %s: %s (File Not Found)\n",
             bundleSymbolicName, sourceRoot);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:OSGiWrapper.java


示例9: includeDirectory

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private void includeDirectory(Jar jar, String destinationRoot, Path sourceRoot)
        throws IOException {
    // iterate through sources
    // put each source on the jar
    FileVisitor<Path> visitor = new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            Path relativePath = sourceRoot.relativize(file);
            String destination = destinationRoot != null ?
                    destinationRoot + "/" + relativePath.toString() : //TODO
                    relativePath.toString();

            addFileToJar(jar, destination, file.toAbsolutePath().toString());
            return FileVisitResult.CONTINUE;
        }
    };

    walkFileTree(sourceRoot, visitor);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:OSGiWrapper.java


示例10: getRange

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private String getRange(Analyzer analyzer) throws Exception {
    if (foundRange != null) {
        return foundRange;
    }
    if (Strings.isNullOrEmpty(value)) {
        for (Jar jar : analyzer.getClasspath()) {
            if (isProvidedByJar(jar) && jar.getVersion() != null) {
                foundRange = jar.getVersion();
                return jar.getVersion();
            }
        }
        // Cannot find a provider.
        reporter.error("Cannot find a dependency providing " + name + " in the classpath");
        return null;
    } else {
        return value;
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:19,代码来源:ImportedPackageRangeFixer.java


示例11: computeClassPath

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
static Jar[] computeClassPath(File basedir) throws IOException {
    List<Jar> list = new ArrayList<>();
    File classes = new File(basedir, "target/classes");

    if (classes.isDirectory()) {
        list.add(new Jar("", classes));
    }

    Set<Artifact> artifacts = load(basedir).getTransitiveDependencies();

    for (Artifact artifact : artifacts) {
        if (!"test".equalsIgnoreCase(artifact.getScope())
                && artifact.getArtifactHandler().isAddedToClasspath()) {
            File file = artifact.getFile();
            if (file.getName().endsWith(".jar") && file.isFile()) {
                list.add(new Jar(artifact.getArtifactId(), file));
            }
        }
    }

    Jar[] cp = new Jar[list.size()];
    list.toArray(cp);

    return cp;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:26,代码来源:Classpath.java


示例12: includeFiles

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private void includeFiles(Jar jar, String destinationRoot, String sourceRoot)
        throws IOException {
    Path sourceRootPath = Paths.get(sourceRoot);
    // iterate through sources
    // put each source on the jar
    FileVisitor<Path> visitor = new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            Path relativePath = sourceRootPath.relativize(file);
            String destination = destinationRoot != null ?
                    destinationRoot + "/" + relativePath.toString() : //TODO
                    relativePath.toString();

            addFileToJar(jar, destination, file.toAbsolutePath().toString());
            return FileVisitResult.CONTINUE;
        }
    };
    File dir = new File(sourceRoot);
    if (dir.isFile()) {
        addFileToJar(jar, destinationRoot, dir.getAbsolutePath());
    } else if (dir.isDirectory()) {
        walkFileTree(sourceRootPath, visitor);
    } else {
        warn("Skipping resource in bundle %s: %s (File Not Found)\n",
             bundleSymbolicName, sourceRoot);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:OSGiWrapper.java


示例13: wrap

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
/**
 * Wrap the file associated with this instance of {@code JarWrapper} if it is not a bundle already.
 * <p>
 * If the source file is already a bundle, nothing is done and this method returns the original file.
 * Notice that this means the returned file is not necessarily the same as the destination file.
 *
 * @param version version to give the bundle. If this is not a valid OSGi version, it will be converted to
 *                a {@link MavenVersion} and translated to a valid OSGi version.
 * @return the bundle file
 * @throws Exception if any error occurs while reading the source file or writing the destination bundle.
 */
public File wrap( String version ) throws Exception {
    if ( !jarFile.isFile() ) {
        throw new IllegalArgumentException( "Not a file: " + jarFile );
    }
    if ( version.trim().isEmpty() ) {
        throw new IllegalArgumentException( "Version must not be empty" );
    }

    try ( ZipFile input = new ZipFile( jarFile, ZipFile.OPEN_READ ) ) {
        if ( isBundle( input ) ) {
            return jarFile;
        }
    }

    final String name = ( artifactName == null ?
            subtract( jarFile.getName(), ".jar" ) : artifactName );

    try ( Jar newJar = new Jar( jarFile ) ) {
        Analyzer analyzer = new Analyzer();
        analyzer.setJar( newJar );
        analyzer.setBundleVersion( Version.isVersion( version ) ?
                Version.parseVersion( version ) :
                MavenVersion.parseString( version ).getOSGiVersion() );
        analyzer.setBundleSymbolicName( name );
        analyzer.setImportPackage( importInstructions );
        analyzer.setExportPackage( exportInstructions );

        File bundle = destination == null ?
                new File( jarFile.getParentFile(), name + "-osgi.jar" ) :
                destination;

        Manifest manifest = analyzer.calcManifest();

        return updateManifest( newJar, bundle, manifest );
    }
}
 
开发者ID:renatoathaydes,项目名称:osgiaas,代码行数:48,代码来源:JarWrapper.java


示例14: updateManifest

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private static File updateManifest( Jar newJar, File bundle, Manifest manifest )
        throws Exception {
    verifyDestinationFileCanBeWritten( bundle );
    newJar.setManifest( manifest );
    newJar.write( bundle );
    return bundle;
}
 
开发者ID:renatoathaydes,项目名称:osgiaas,代码行数:8,代码来源:JarWrapper.java


示例15: loadOldClassesFromFolder

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
@Override
public void loadOldClassesFromFolder(File jarFile) throws RuntimeException {
	try {
		oldJar = new Jar(jarFile);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}

}
 
开发者ID:cbrun,项目名称:baseliner,代码行数:10,代码来源:BndApiComparator.java


示例16: isProvidedByJar

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private boolean isProvidedByJar(Jar jar) {
    for (String s : jar.getPackages()) {
        if (matches(s)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:9,代码来源:ImportedPackageRangeFixer.java


示例17: testWithoutReferred

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
@Test
public void testWithoutReferred() throws Exception {
    ImportedPackageRangeFixer fixer = new ImportedPackageRangeFixer();
    Reporter reporter = mock(Reporter.class);
    fixer.setReporter(reporter);
    fixer.setProperties(Collections.<String, String>emptyMap());

    Analyzer analyzer = new Analyzer();
    analyzer.setClasspath(new Jar[] {
            new Jar("foo")
    });
    fixer.analyzeJar(analyzer);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:14,代码来源:ImportedPackageRangeFixerTest.java


示例18: createJarFromClasspath

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
private Jar createJarFromClasspath(String name) throws IOException {
    List<URL> list = new ArrayList<>();
    if (this.getClass().getClassLoader() instanceof URLClassLoader) {
        URL[] urls = ((URLClassLoader) this.getClass().getClassLoader()).getURLs();
        for (URL url : urls) {
            list.add(url);
            if (url.toExternalForm().contains(name)) {
                return new Jar(url.getFile(), url.getPath());
            }
        }
    }

    throw new IllegalArgumentException("Cannot find " + name + " in classpath - " + list);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:15,代码来源:ImportedPackageRangeFixerTest.java


示例19: build

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
/**
 * Adds all the resources found in the given classpath to the given jar. Are excluded resources matching the
 * 'doNotCopy' pattern.
 *
 * @param jar       the jar in which the resources are added
 * @param classpath the classpath
 * @param doNotCopy the do not copy pattern
 */
public static void build(Jar jar, ClassPath classpath, Pattern doNotCopy) {
    ImmutableSet<ClassPath.ResourceInfo> resources = classpath.getResources();
    for (ClassPath.ResourceInfo resource : resources) {
        if (doNotCopy != null && doNotCopy.matcher(resource.getResourceName()).matches()) {
            continue;
        }
        jar.putResource(resource.getResourceName(), new ClassPathResource(resource));
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:18,代码来源:ClassPathResource.java


示例20: execute

import aQute.bnd.osgi.Jar; //导入依赖的package包/类
public boolean execute() {
        Analyzer analyzer = new Builder();
        try {

            Jar jar = new Jar(new File(inputJar));  // where our data is
            analyzer.setJar(jar);                   // give bnd the contents

            // You can provide additional class path entries to allow
            // bnd to pickup export version from the packageinfo file,
            // Version annotation, or their manifests.
            analyzer.addClasspath(classpath);

            setProperties(analyzer);

//            analyzer.setProperty("DESTDIR");
//            analyzer.setBase();

            // ------------- let's begin... -------------------------

            // Analyze the target JAR first
            analyzer.analyze();

            // Scan the JAR for Felix SCR annotations and generate XML files
            Map<String, String> properties = Maps.newHashMap();
            SCRDescriptorBndPlugin scrDescriptorBndPlugin = new SCRDescriptorBndPlugin();
            scrDescriptorBndPlugin.setProperties(properties);
            scrDescriptorBndPlugin.setReporter(analyzer);
            scrDescriptorBndPlugin.analyzeJar(analyzer);

            if (includeResources != null) {
                doIncludeResources(analyzer);
            }

            // Repack the JAR as a WAR
            doWabStaging(analyzer);

            // Calculate the manifest
            Manifest manifest = analyzer.calcManifest();
            //OutputStream s = new FileOutputStream("/tmp/foo2.txt");
            //manifest.write(s);
            //s.close();

            if (analyzer.isOk()) {
                analyzer.getJar().setManifest(manifest);
                if (analyzer.save(new File(outputJar), true)) {
                    log("Saved!\n");
                } else {
                    warn("Failed to create jar \n");
                    return false;
                }
            } else {
                warn("Analyzer Errors:\n%s\n", analyzer.getErrors());
                return false;
            }

            analyzer.close();

            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:64,代码来源:OSGiWrapper.java



注:本文中的aQute.bnd.osgi.Jar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileToStreamDecoder类代码示例发布时间:2022-05-22
下一篇:
Java SOAPVersion类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap