本文整理匯總了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();
}
示例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());
}
示例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);
}
}
示例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()));
}