コード例 #1
0
 public synchronized void attachFragment(BundleFragment fragment) throws BundleException {
   ExportPackageDescription[] exports = proxy.getBundleDescription().getSelectedExports();
   if (classloader == null) {
     initializeExports(exports, exportedPackages);
     return;
   }
   String[] classpath = fragment.getBundleData().getClassPath();
   if (classpath != null)
     classloader.attachFragment(
         fragment.getBundleData(), fragment.getProtectionDomain(), classpath);
   initializeExports(exports, exportedPackages);
 }
コード例 #2
0
  BundleClassLoader createBCL(final BundleProtectionDomain pd, final String[] cp) {
    BundleClassLoader bcl = bundle.getBundleData().createClassLoader(BundleLoader.this, pd, cp);
    // attach existing fragments to classloader
    BundleFragment[] fragments = bundle.getFragments();
    if (fragments != null)
      for (int i = 0; i < fragments.length; i++) {
        try {
          bcl.attachFragment(
              fragments[i].getBundleData(),
              fragments[i].getProtectionDomain(),
              fragments[i].getBundleData().getClassPath());
        } catch (BundleException be) {
          bundle.getFramework().publishFrameworkEvent(FrameworkEvent.ERROR, bundle, be);
        }
      }

    // finish the initialization of the classloader.
    bcl.initialize();
    return bcl;
  }