Example #1
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;
  }
Example #2
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);
  }
  @Override
  public BundleEntry getEntry(String path) {

    final BundleEntry original = delegate.getEntry(path);
    if (data.getBundle() == null || path == null || original == null) {
      return original;
    }

    LazyInputStream stream =
        new LazyInputStream(
            new InputStreamProvider() {

              @Override
              public InputStream getInputStream() throws IOException {
                return original.getInputStream();
              }
            });
    InputStream wrappedStream = getInputStream(stream, data.getBundle(), path);
    if (wrappedStream == null) {
      return original;
    }
    return new TransformedBundleEntry(this, original, wrappedStream);
  }
Example #4
0
 /**
  * This will set the equinox classpath of <code>bundle</code> to reflect the eclipse classpath of
  * <code>plugin</code>.
  *
  * @param plugin The eclipse plugin which classpath is to be set for its corresponding equinox
  *     bundle.
  * @param bundle The equinox bundle which classpath is to reflect an eclipse development plugin.
  */
 @SuppressWarnings("restriction")
 /*
  * This methods sports a number of restricted class/method usage, yet there is no workaround and the
  * equinox team has no plan to open it. We're suppressing the warning until plans change. Details in bug
  * 271761.
  */
 private void setBundleClasspath(IProject plugin, Bundle bundle) {
   final Set<String> classpathEntries = getOutputFolders(plugin);
   if (classpathEntries.size() > 0) {
     final org.eclipse.osgi.baseadaptor.BaseData bundleData =
         (org.eclipse.osgi.baseadaptor.BaseData)
             ((org.eclipse.osgi.framework.internal.core.AbstractBundle) bundle).getBundleData();
     final StringBuilder classpath = new StringBuilder();
     classpath.append(bundleData.getClassPathString()).append(',');
     final Iterator<String> entryIterator = classpathEntries.iterator();
     while (entryIterator.hasNext()) {
       classpath.append(entryIterator.next());
       if (entryIterator.hasNext()) {
         classpath.append(',');
       }
     }
     bundleData.setClassPathString(classpath.toString());
   }
 }
 protected File getExtractFile(String entryName) {
   if (data == null) {
     return null;
   }
   String path = ".tf"; /* put all these entries in this subdir */ // $NON-NLS-1$
   String name = entryName.replace('/', File.separatorChar);
   /*
    * if name has a leading slash
    */
   if ((name.length() > 1) && (name.charAt(0) == File.separatorChar)) {
     path = path.concat(name);
   } else {
     path = path + File.separator + name;
   }
   return data.getExtractFile(path);
 }
Example #6
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;
  }
 /**
  * Answers whether the resource at the given path or any of its children has a transform
  * associated with it.
  *
  * @param path
  * @return whether the resource at the given path or any of its children has a transform
  *     associated with it.
  */
 private boolean hasTransforms(String path) {
   if (!transformers.hasTransformers()) {
     return false;
   }
   return templates.hasTransformsFor(data.getBundle());
 }