當前位置: 首頁>>代碼示例>>Java>>正文


Java FileArchive類代碼示例

本文整理匯總了Java中org.apache.xbean.finder.archive.FileArchive的典型用法代碼示例。如果您正苦於以下問題:Java FileArchive類的具體用法?Java FileArchive怎麽用?Java FileArchive使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileArchive類屬於org.apache.xbean.finder.archive包,在下文中一共展示了FileArchive類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: finderFromClasses

import org.apache.xbean.finder.archive.FileArchive; //導入依賴的package包/類
private static IAnnotationFinder finderFromClasses(final DeploymentModule module, final Class<?>[] value, final Collection<File> others, final String[] excludes) {
    final Collection<Archive> archives = new ArrayList<>(1 + (others == null ? 0 : others.size()));

    final Filter filter = excludes == null || excludes.length == 0 ? null : Filters.invert(Filters.prefixes(excludes));

    final Collection<Class<?>> classes = new ArrayList<>(asList(FinderFactory.ensureMinimalClasses(module)));
    if (value != null) {
        classes.addAll(asList(value));
    }
    final ClassesArchive classesArchive = new ClassesArchive(classes);
    archives.add(filter == null ? classesArchive : new FilteredArchive(classesArchive, filter));

    if (others != null) {
        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        for (final File f : others) {
            try {
                final Archive archive = f.isDirectory() ? new FileArchive(classLoader, f) : new JarArchive(classLoader, f.toURI().toURL());
                archives.add(filter == null ? archive : new FilteredArchive(archive, filter));
            } catch (final MalformedURLException e) {
                throw new IllegalArgumentException(e);
            }
        }
    }
    return new FinderFactory.OpenEJBAnnotationFinder(new CompositeArchive(archives)).link();
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:26,代碼來源:ApplicationComposers.java

示例2: getClassReaders

import org.apache.xbean.finder.archive.FileArchive; //導入依賴的package包/類
@Override
public List<ClassReader> getClassReaders() throws IOException {
	
	
	List<Archive> archives = new ArrayList<>();
	for (String basePackage : basePackages) {
		Enumeration<URL> resources = ClasspathBytecodeSource.class.getClassLoader().getResources(basePackage.replace('.', '/'));
		while(resources.hasMoreElements()) {
			URL url = resources.nextElement();
			if ("zip".equals(url.getProtocol()) || "jar".equals(url.getProtocol())) {
				archives.add(new JarArchive(classLoader, url));
			} else {
				archives.add(new FileArchive(classLoader, url, basePackage));
			}
		}
	}
	
	CompositeArchive compositeArchive = new CompositeArchive(archives);

	return StreamSupport.stream(compositeArchive.spliterator(), false)
			.map(new Function<Archive.Entry, ClassReader>() {
				@Override
				public ClassReader apply(Archive.Entry t) {
					try {
						return new ClassReader(t.getBytecode());
					} catch(IOException e) {
						//TODO
						System.out.println("EXC");
						return null;
					}
				}				
			})
			.filter(x -> x != null)
			.collect(Collectors.toList());
}
 
開發者ID:axt,項目名稱:jvm-callgraph,代碼行數:36,代碼來源:ClasspathBytecodeSource.java

示例3: getArchivesForPackage

import org.apache.xbean.finder.archive.FileArchive; //導入依賴的package包/類
private static CompositeArchive getArchivesForPackage(final ClassLoader classloader, final String... packages)
{
	try
	{
		final List<Archive> archives = new ArrayList<>();

		for (String pkg : packages)
		{
			if (!pkg.endsWith("."))
				pkg += "."; // Add a trailing dot for easier package matching

			final String baseFolder = pkg.replace('.', '/');

			final Enumeration<URL> urls = classloader.getResources(baseFolder);

			while (urls.hasMoreElements())
			{
				final URL url = urls.nextElement();

				if (log.isTraceEnabled())
					log.trace("Found source: " + url);

				if (url.getProtocol() != null && (url.getProtocol().equals("zip") || url.getProtocol().equals("jar")))
					archives.add(new FilteredArchive(new JarArchive(classloader, url), new PrefixFilter(pkg)));
				else
					archives.add(new FileArchive(classloader, url, pkg));
			}
		}

		return new CompositeArchive(archives);
	}
	catch (IOException e)
	{
		throw new IllegalArgumentException("Error loading archives for packages: " + Arrays.asList(packages), e);
	}
}
 
開發者ID:petergeneric,項目名稱:stdlib,代碼行數:37,代碼來源:ClassScannerFactory.java

示例4: installJaas

import org.apache.xbean.finder.archive.FileArchive; //導入依賴的package包/類
@SuppressWarnings("deprecation")
protected static void installJaas() {
    final String path = SystemInstance.get().getOptions().get("java.security.auth.login.config", (String) null);

    if (path != null) {
        return;
    }

    final URL loginConfig = ConfUtils.getConfResource("login.config");
    JavaSecurityManagers.setSystemProperty("java.security.auth.login.config", FileArchive.decode(loginConfig.toExternalForm()));
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:12,代碼來源:SecurityServiceImpl.java


注:本文中的org.apache.xbean.finder.archive.FileArchive類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。