org.aspectj.weaver.loadtime

## Class Aj

- java.lang.Object
- - org.aspectj.weaver.loadtime.Aj

All Implemented Interfaces:
  ClassPreProcessor

    public class Aj
    extends java.lang.Object
    implements ClassPreProcessor

Adapter between the generic class pre processor interface and the AspectJ weaver Load time weaving consistency relies on Bcel.setRepository

Author:
  Alexandre Vasseur

### Field Summary

Fields
`static org.aspectj.weaver.tools.cache.SimpleCache` `laCache`
`static java.util.List<java.lang.String>` `loadersToSkip`

### Constructor Summary

Constructors
Constructor and Description
`Aj()`
`Aj(IWeavingContext context)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static void` `checkQ()` Process the reference queue that contains stale AdaptorKeys - the keys are put on the queue when their classloader referent is garbage collected and so the associated adaptor (weaver) should be removed from the map
`void` `flushGeneratedClasses(java.lang.ClassLoader loader)`
`boolean` `generatedClassesExist(java.lang.ClassLoader loader)` Check to see if any classes have been generated for a particular classes loader.
`static int` `getActiveAdaptorCount()`
`java.lang.String` `getNamespace(java.lang.ClassLoader loader)` Returns a namespace based on the contest of the aspects available
`void` `initialize()` Initialization
`void` `prepareForRedefinition(java.lang.ClassLoader loader, java.lang.String className)`
`byte[]` `preProcess(java.lang.String className, byte[] bytes, java.lang.ClassLoader loader, java.security.ProtectionDomain protectionDomain)`
`static int` `removeStaleAdaptors(boolean displayProgress)` The reference queue is only processed when a request is made for a weaver adaptor.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### laCache

    public static org.aspectj.weaver.tools.cache.SimpleCache laCache

#### loadersToSkip

    public static java.util.List<java.lang.String> loadersToSkip

### Constructor Detail

#### Aj

    public Aj()

#### Aj

    public Aj(IWeavingContext context)

### Method Detail

#### initialize

    public void initialize()

Initialization

Specified by:
  `initialize` in interface `ClassPreProcessor`

#### preProcess

    public byte[] preProcess(java.lang.String className,
                             byte[] bytes,
                             java.lang.ClassLoader loader,
                             java.security.ProtectionDomain protectionDomain)

Specified by:
  `preProcess` in interface `ClassPreProcessor`

#### removeStaleAdaptors

    public static int removeStaleAdaptors(boolean displayProgress)

The reference queue is only processed when a request is made for a weaver adaptor. This means there can be one or two stale weavers left around. If the user knows they have finished all their weaving, they might wish to call removeStaleAdaptors which will process anything left on the reference queue containing adaptorKeys for garbage collected classloaders.

Parameters:
  `displayProgress` - produce System.err info on the tidying up process
Returns:
  number of stale weavers removed

#### getActiveAdaptorCount

    public static int getActiveAdaptorCount()

Returns:
  the number of entries still in the weavingAdaptors map

#### checkQ

    public static void checkQ()

Process the reference queue that contains stale AdaptorKeys - the keys are put on the queue when their classloader referent is garbage collected and so the associated adaptor (weaver) should be removed from the map

#### getNamespace

    public java.lang.String getNamespace(java.lang.ClassLoader loader)

Returns a namespace based on the contest of the aspects available

#### generatedClassesExist

    public boolean generatedClassesExist(java.lang.ClassLoader loader)

Check to see if any classes have been generated for a particular classes loader. Calls ClassLoaderWeavingAdaptor.generatedClassesExist()

Parameters:
  `loader` - the class cloder
Returns:
  true if classes have been generated.

#### flushGeneratedClasses

    public void flushGeneratedClasses(java.lang.ClassLoader loader)

#### prepareForRedefinition

    public void prepareForRedefinition(java.lang.ClassLoader loader,
                                       java.lang.String className)

Specified by:
  `prepareForRedefinition` in interface `ClassPreProcessor`