Esempio n. 1
0
  private void initialize(final BundleContext context) {
    if (Debug.DEBUG_GENERAL) Debug.println("> AspectJHook.initialize() context=" + context);

    this.bundleContext = context;

    final ISupplementerRegistry supplementerRegistry = getSupplementerRegistry();
    adaptorFactory.initialize(context, supplementerRegistry);

    final ServiceReference serviceReference =
        context.getServiceReference(PackageAdmin.class.getName());
    final PackageAdmin packageAdmin = (PackageAdmin) context.getService(serviceReference);

    supplementerRegistry.setBundleContext(context);
    supplementerRegistry.setPackageAdmin(packageAdmin);
    context.addBundleListener(new SupplementBundleListener(supplementerRegistry));

    // final re-build supplementer final registry state for final installed bundles
    final Bundle[] installedBundles = context.getBundles();
    for (int i = 0; i < installedBundles.length; i++) {
      supplementerRegistry.addSupplementer(installedBundles[i], false);
    }
    for (int i = 0; i < installedBundles.length; i++) {
      supplementerRegistry.addSupplementedBundle(installedBundles[i]);
    }

    if (Debug.DEBUG_GENERAL)
      Debug.println("< AspectJHook.initialize() adaptorFactory=" + adaptorFactory);
  }
Esempio n. 2
0
  @Override
  public BundleFile wrapBundleFile(
      final BundleFile bundleFile, final Object content, final BaseData data, final boolean base)
      throws IOException {
    BundleFile wrapped = null;
    if (Debug.DEBUG_BUNDLE)
      Debug.println(
          "> AspectJBundleFileWrapperFactoryHook.wrapBundleFile() bundle="
              + data.getSymbolicName()
              + " bundleFile="
              + bundleFile
              + ", content="
              + content
              + ", data="
              + data
              + ", base="
              + base
              + ", baseFile="
              + bundleFile.getBaseFile());

    if (base) {
      wrapped = new BaseWeavingBundleFile(new BundleAdaptorProvider(data, this), bundleFile);
    } else {
      wrapped = new WeavingBundleFile(new BundleAdaptorProvider(data, this), bundleFile);
    }
    if (Debug.DEBUG_BUNDLE)
      Debug.println("< AspectJBundleFileWrapperFactoryHook.wrapBundleFile() wrapped=" + wrapped);
    return wrapped;
  }
Esempio n. 3
0
  private IWeavingAdaptor createAspectJAdaptor(final BaseData baseData) {
    if (Debug.DEBUG_GENERAL)
      Debug.println("> AspectJHook.createAspectJAdaptor() location=" + baseData.getLocation());
    IWeavingAdaptor adaptor = null;

    if (adaptorFactory != null) {
      adaptor = new WeavingAdaptor(baseData, adaptorFactory, null, null, null);
    } else {
      if (Debug.DEBUG_GENERAL)
        Debug.println("- AspectJHook.createAspectJAdaptor() factory=" + adaptorFactory);
    }

    if (Debug.DEBUG_GENERAL)
      Debug.println("< AspectJHook.createAspectJAdaptor() adaptor=" + adaptor);
    return adaptor;
  }
Esempio n. 4
0
  /**
   * @see
   *     org.eclipse.equinox.weaving.hooks.AbstractWeavingHook#initializedClassLoader(org.eclipse.osgi.baseadaptor.loader.BaseClassLoader,
   *     org.eclipse.osgi.baseadaptor.BaseData)
   */
  @Override
  public void initializedClassLoader(final BaseClassLoader baseClassLoader, final BaseData data) {
    if (Debug.DEBUG_GENERAL)
      Debug.println(
          "> AspectJHook.initializedClassLoader() bundle="
              + data.getSymbolicName()
              + ", loader="
              + baseClassLoader
              + ", data="
              + data
              + ", bundleFile="
              + data.getBundleFile());

    final IWeavingAdaptor adaptor = createAspectJAdaptor(data);
    adaptor.setBaseClassLoader(baseClassLoader);
    adaptor.initialize();
    this.adaptors.put(data.getBundleID(), adaptor);

    if (Debug.DEBUG_GENERAL)
      Debug.println("< AspectJHook.initializedClassLoader() adaptor=" + adaptor);
  }
Esempio n. 5
0
 public WeavingHook() {
   if (Debug.DEBUG_GENERAL) Debug.println("- AspectJHook.<init>()");
   this.adaptorFactory = new WeavingAdaptorFactory();
   this.adaptors = new HashMap<Long, IWeavingAdaptor>();
 }