Skip to content

Commit

Permalink
Format java files in o.e.equinox.weaving.hook
Browse files Browse the repository at this point in the history
This was achieved by running:
eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
  -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d`

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
  • Loading branch information
Torbjorn-Svensson authored and akurtakov committed Nov 3, 2023
1 parent 2bfdd0a commit 6e4051c
Show file tree
Hide file tree
Showing 24 changed files with 1,793 additions and 1,913 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,41 @@
*/
public class CacheEntry {

private final byte[] cachedBytes;
private final byte[] cachedBytes;

private final boolean dontWeave;
private final boolean dontWeave;

/**
* Creates a new cache entry. This item can tell the basic hook mechanism to
* use the given cached bytes for the class definition or if the original
* class bytes needs weaving or not
*
* @param dontWeave A flag that indicates whether this item needs to be
* woven or not
* @param cachedBytes The bytes for the class read from the cache
*/
public CacheEntry(final boolean dontWeave, final byte[] cachedBytes) {
this.dontWeave = dontWeave;
this.cachedBytes = cachedBytes;
}
/**
* Creates a new cache entry. This item can tell the basic hook mechanism to use
* the given cached bytes for the class definition or if the original class
* bytes needs weaving or not
*
* @param dontWeave A flag that indicates whether this item needs to be woven
* or not
* @param cachedBytes The bytes for the class read from the cache
*/
public CacheEntry(final boolean dontWeave, final byte[] cachedBytes) {
this.dontWeave = dontWeave;
this.cachedBytes = cachedBytes;
}

/**
* Tell the hook mechanism to weave a class or not to weave a class
*
* @return true, if the class doesn't need any weaving, otherwise false
*/
public boolean dontWeave() {
return dontWeave;
}
/**
* Tell the hook mechanism to weave a class or not to weave a class
*
* @return true, if the class doesn't need any weaving, otherwise false
*/
public boolean dontWeave() {
return dontWeave;
}

/**
* Returns the bytes that are read from the cache. These bytes should be
* used for defining the class instead of the original ones.
*
* @return The cached bytes for the class
*/
public byte[] getCachedBytes() {
return cachedBytes;
}
/**
* Returns the bytes that are read from the cache. These bytes should be used
* for defining the class instead of the original ones.
*
* @return The cached bytes for the class
*/
public byte[] getCachedBytes() {
return cachedBytes;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@

public interface ICachingService {

public boolean canCacheGeneratedClasses();
public boolean canCacheGeneratedClasses();

public CacheEntry findStoredClass(String namespace, URL sourceFileURL,
String name);
public CacheEntry findStoredClass(String namespace, URL sourceFileURL, String name);

public void stop();
public void stop();

public boolean storeClass(String namespace, URL sourceFileURL,
Class<?> clazz, byte[] classbytes);
public boolean storeClass(String namespace, URL sourceFileURL, Class<?> clazz, byte[] classbytes);

public boolean storeClassAndGeneratedClasses(String namespace,
URL sourceFileURL, Class<?> clazz, byte[] classbytes,
Map<String, byte[]> generatedClasses);
public boolean storeClassAndGeneratedClasses(String namespace, URL sourceFileURL, Class<?> clazz, byte[] classbytes,
Map<String, byte[]> generatedClasses);

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@
*/
public interface ICachingServiceFactory {

/**
* Create concrete caching service for the given bundle. The caching service
* is then responsible to cache woven bytecode and retrieve those bytecodes
* from the cache.
*
* @param classLoader The classloader if the given bundle
* @param bundle The bundle the caching service should be created for
* @param key A fingerprint that is created by the concrete weavers to
* indicate what the weaving configuration for this bundle is.
* The caching service should be able to handle different keys
* for the same bundle in order not the deliver the wrong cached
* bytes from the cache
* @return The caching service for the given bundle
*/
public ICachingService createCachingService(ClassLoader classLoader,
Bundle bundle, String key);
/**
* Create concrete caching service for the given bundle. The caching service is
* then responsible to cache woven bytecode and retrieve those bytecodes from
* the cache.
*
* @param classLoader The classloader if the given bundle
* @param bundle The bundle the caching service should be created for
* @param key A fingerprint that is created by the concrete weavers to
* indicate what the weaving configuration for this bundle
* is. The caching service should be able to handle different
* keys for the same bundle in order not the deliver the
* wrong cached bytes from the cache
* @return The caching service for the given bundle
*/
public ICachingService createCachingService(ClassLoader classLoader, Bundle bundle, String key);

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,32 @@

public interface ISupplementerRegistry {

public void addBundle(final Bundle bundle);
public void addBundle(final Bundle bundle);

public void addSupplementedBundle(final Bundle bundle);
public void addSupplementedBundle(final Bundle bundle);

public void addSupplementer(final Bundle bundle, final boolean updateBundles);
public void addSupplementer(final Bundle bundle, final boolean updateBundles);

public List<Supplementer> getMatchingSupplementers(
final String symbolicName, final ManifestElement[] imports,
final ManifestElement[] exports);
public List<Supplementer> getMatchingSupplementers(final String symbolicName, final ManifestElement[] imports,
final ManifestElement[] exports);

public PackageAdmin getPackageAdmin();
public PackageAdmin getPackageAdmin();

public Supplementer[] getSupplementers(final Bundle bundle);
public Supplementer[] getSupplementers(final Bundle bundle);

public Supplementer[] getSupplementers(final long bundleID);
public Supplementer[] getSupplementers(final long bundleID);

/**
* Refreshes the given bundles
*
* @param bundles The bundles to refresh
*/
public void refreshBundles(final Bundle[] bundles);
/**
* Refreshes the given bundles
*
* @param bundles The bundles to refresh
*/
public void refreshBundles(final Bundle[] bundles);

public void removeBundle(final Bundle bundle);
public void removeBundle(final Bundle bundle);

public void setBundleContext(final BundleContext context);
public void setBundleContext(final BundleContext context);

public void setPackageAdmin(final PackageAdmin packageAdmin);
public void setPackageAdmin(final PackageAdmin packageAdmin);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,62 @@
*/
public interface IWeavingService {

/**
* Flush all generated classes from the weaving service so that memory kept
* by the weaving service for additional classes can be freed.
*
* @param loader The class loader the weaving service belongs to
*/
public void flushGeneratedClasses(ClassLoader loader);
/**
* Flush all generated classes from the weaving service so that memory kept by
* the weaving service for additional classes can be freed.
*
* @param loader The class loader the weaving service belongs to
*/
public void flushGeneratedClasses(ClassLoader loader);

/**
* Has the weaving service generated new classes on the fly for the given
* class?
*
* @param loader The class loader of the woven class
* @param className The name of the woven class
* @return true, if the weaving service has generated additional classes for
* the woven class (closures, for example)
*/
public boolean generatedClassesExistFor(ClassLoader loader, String className);
/**
* Has the weaving service generated new classes on the fly for the given class?
*
* @param loader The class loader of the woven class
* @param className The name of the woven class
* @return true, if the weaving service has generated additional classes for the
* woven class (closures, for example)
*/
public boolean generatedClassesExistFor(ClassLoader loader, String className);

/**
* Returns a map that contains all generated classes for the given class.
* Implementations of this method should remove those classes from internal
* lists (to free memory). This means also that calling this method a second
* time will return an emptry map.
*
* @param className The name of the class for which additional classes were
* generated
* @return The generated classes (key: generated class name, value:
* generated class bytecode)
*/
public Map<String, byte[]> getGeneratedClassesFor(String className);
/**
* Returns a map that contains all generated classes for the given class.
* Implementations of this method should remove those classes from internal
* lists (to free memory). This means also that calling this method a second
* time will return an emptry map.
*
* @param className The name of the class for which additional classes were
* generated
* @return The generated classes (key: generated class name, value: generated
* class bytecode)
*/
public Map<String, byte[]> getGeneratedClassesFor(String className);

/**
* The key of a concrete weaver for a bundle defines the setting in which
* the weaver works. This key typically defines a unique key for the set of
* aspects which are woven into this bundle. The core equinox aspects
* runtime uses this key to feed the caching service. This means, the weaver
* should return different keys for different set of aspects (including
* versions), respectively when the cache should switch its context.
*
* @return A unique key to define the set of aspects that are woven into the
* bundle to which this weaver belongs
*/
public String getKey();
/**
* The key of a concrete weaver for a bundle defines the setting in which the
* weaver works. This key typically defines a unique key for the set of aspects
* which are woven into this bundle. The core equinox aspects runtime uses this
* key to feed the caching service. This means, the weaver should return
* different keys for different set of aspects (including versions),
* respectively when the cache should switch its context.
*
* @return A unique key to define the set of aspects that are woven into the
* bundle to which this weaver belongs
*/
public String getKey();

/**
* This method is called for each class which is loaded into the JVM and not
* read from cache to do the actual weaving, if necessary.
*
* @param name The fully qualified name of the class to be loaded
* @param classbytes The original unmodified bytecode of the class read by
* the standard OSGi classloading mechanism
* @param loader The classloader whichi s responsible for loading the class
* @return The modified (woven) bytecode of the class or null, if no
* modification happened
* @throws IOException
*/
public byte[] preProcess(String name, byte[] classbytes, ClassLoader loader)
throws IOException;
/**
* This method is called for each class which is loaded into the JVM and not
* read from cache to do the actual weaving, if necessary.
*
* @param name The fully qualified name of the class to be loaded
* @param classbytes The original unmodified bytecode of the class read by the
* standard OSGi classloading mechanism
* @param loader The classloader whichi s responsible for loading the class
* @return The modified (woven) bytecode of the class or null, if no
* modification happened
* @throws IOException
*/
public byte[] preProcess(String name, byte[] classbytes, ClassLoader loader) throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
*/
public interface IWeavingServiceFactory {

/**
* Create a concrete weaving implementation for the given bundle. This is
* called by the basic equinox aspects weaving hook mechanism lazily when
* the classloader for the bundle is created.
*
* @param loader The classloader of the bundle for which to create a weaver
* @param bundle The bundle for which to create the weaver
* @param bundleRevision The revision of the bundle for which to create a
* weaver
* @param supplementerRegistry The supplementer registry which is used by
* the core equinox aspects hook
* @return The created weaver for the given bundle
*/
public IWeavingService createWeavingService(ClassLoader loader,
Bundle bundle, BundleRevision bundleRevision,
ISupplementerRegistry supplementerRegistry);
/**
* Create a concrete weaving implementation for the given bundle. This is called
* by the basic equinox aspects weaving hook mechanism lazily when the
* classloader for the bundle is created.
*
* @param loader The classloader of the bundle for which to create
* a weaver
* @param bundle The bundle for which to create the weaver
* @param bundleRevision The revision of the bundle for which to create a
* weaver
* @param supplementerRegistry The supplementer registry which is used by the
* core equinox aspects hook
* @return The created weaver for the given bundle
*/
public IWeavingService createWeavingService(ClassLoader loader, Bundle bundle, BundleRevision bundleRevision,
ISupplementerRegistry supplementerRegistry);

}
Loading

0 comments on commit 6e4051c

Please sign in to comment.