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); }
@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; }
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; }
/** * @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); }
public WeavingHook() { if (Debug.DEBUG_GENERAL) Debug.println("- AspectJHook.<init>()"); this.adaptorFactory = new WeavingAdaptorFactory(); this.adaptors = new HashMap<Long, IWeavingAdaptor>(); }