public static void main(String[] args) throws Exception { DirectoryBundleFile bf = new DirectoryBundleFile( new File("/Users/bstefanescu/work/org.eclipse.ecr/plugins/org.eclipse.ecr.application/bin")); Enumeration<URL> urls = bf.findEntries("META-INF", "*.txt", false); while (urls.hasMoreElements()) { System.out.println(urls.nextElement()); } }
@Override public Collection<BundleFile> findNestedBundles(File tmpDir) throws IOException { List<BundleFile> nested = new ArrayList<>(); File[] files = FileUtils.findFiles(file, "*.jar", true); for (File jar : files) { if (jar.isDirectory()) { nested.add(new DirectoryBundleFile(jar)); } else { nested.add(new JarBundleFile(jar)); } } return nested; }
/** * Creates the system bundle from the jar specified by the nuxeo.osgi.system.bundle property. */ public static BundleFile createSystemBundle(URL systemBundle) throws IOException { URI uri; try { uri = systemBundle.toURI(); } catch (URISyntaxException e) { throw new IOException(e); } File file = new File(uri); BundleFile sysbf = null; if (file.isFile()) { sysbf = new JarBundleFile(file); } else { sysbf = new DirectoryBundleFile(file); } return sysbf; }
@Override @Deprecated public void deployFolder(File folder, ClassLoader loader) throws Exception { DirectoryBundleFile bf = new DirectoryBundleFile(folder); BundleImpl bundle = new BundleImpl(osgi, bf, loader); osgi.install(bundle); }
@Override public Collection<BundleFile> getNestedBundles(File tmpDir) throws IOException { Attributes attrs = mf.getMainAttributes(); String cp = attrs.getValue(Constants.BUNDLE_CLASSPATH); if (cp == null) { cp = attrs.getValue("Class-Path"); } if (cp == null) { return null; } String[] paths = StringUtils.split(cp, ',', true); List<BundleFile> nested = new ArrayList<>(); for (String path : paths) { File nestedBundle = new File(file, path); if (nestedBundle.isDirectory()) { nested.add(new DirectoryBundleFile(nestedBundle)); } else { nested.add(new JarBundleFile(nestedBundle)); } } return nested; }
File f = new File(line.trim()); if (f.isDirectory()) { bf = new DirectoryBundleFile(f); } else { bf = new JarBundleFile(f);
File f = new File(line.trim()); if (f.isDirectory()) { bf = new DirectoryBundleFile(f); } else { bf = new JarBundleFile(f);
try { if (file.isDirectory()) { bundleFile = new DirectoryBundleFile(file); } else { bundleFile = new JarBundleFile(file);
@Override public int visitDirectory(File file) { // System.out.println("###### Processing DIR: " + file); // first check if this is a possible bundle String fileName = file.getName(); if (patterns != null) { if (!acceptFile(fileName, patterns)) { return FileWalker.CONTINUE; } } // check if this is an OSGi bundle try { Manifest mf = JarUtils.getDirectoryManifest(file); if (mf == null) { return FileWalker.CONTINUE; } String bundleName = mf.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME); if (bundleName != null) { // notify the callback about the new bundle callback.visitBundle(new DirectoryBundleFile(file, mf)); // assume that a directory OSGi bundle cannot contain other bundles so skip it return FileWalker.BREAK; } } catch (IOException e) { log.error(e, e); } return FileWalker.CONTINUE; }
DirectoryBundleFile bf = new DirectoryBundleFile(file); if (bf.getSymbolicName() != null) { bundles.add(bf);
@Override public Bundle installBundle(String location) throws BundleException { File file = new File(location); try { BundleFile bf = file.isDirectory() ? new DirectoryBundleFile(file) : new JarBundleFile(file); BundleImpl b = new BundleImpl(bundle.osgi, bf, bundle.loader); if (b.getSymbolicName() != null) { bundle.osgi.install(b); } return b; } catch (IOException e) { throw new BundleException("Failed to install bundle at " + location, e); } }
public synchronized void deployBundle(File file) throws BundleException, IOException { if (!isStarted()) { throw new IllegalStateException("Framework not started"); } if (!file.getPath().endsWith(".jar")) { return; // not a valid bundle } BundleFile bf = file.isDirectory() ? new DirectoryBundleFile(file) : new JarBundleFile(file); try { BundleImpl bundle = new BundleImpl(osgi, bf, loader); if (bundle.getSymbolicName() != null) { osgi.install(bundle); } } catch (NullPointerException t) { // do nothing: may happen with non OSGi manifests // System.out.println("Ignore: "+file); } }
bf = new DirectoryBundleFile(file); } else { bf = new JarBundleFile(file);
bf = new JarBundleFile(jar); } else if (file.isDirectory()) { bf = new DirectoryBundleFile(file); } else { return;
public static String install(File f) throws IOException, BundleException { BundleFile bf; if (f.isDirectory()) { bf = new DirectoryBundleFile(f); } else { bf = new JarBundleFile(f); } BundleImpl bundle = new BundleImpl(osgi, bf, loader); if (bundle.getState() == 0) { // not a bundle (no Bundle-SymbolicName) return null; } osgi.install(bundle); return bundle.getSymbolicName(); }