private final ConcurrentMap<Bundle, LinkedHashSet<WrappingTransformer>> registeredTransformers
= new ConcurrentHashMap<Bundle, LinkedHashSet<WrappingTransformer>>();
public void weave(WovenClass wovenClass) {
BundleWiring wiring = wovenClass.getBundleWiring();
Collection<WrappingTransformer> transformers = registeredTransformers.get(
wiring.getBundle());
if(transformers != null) {
Collection<WrappingTransformer> transformersToTry;
synchronized (transformers) {
transformersToTry = new ArrayList<WrappingTransformer>(transformers);
}
for(WrappingTransformer transformer : transformersToTry) {
try {
byte[] result = transformer.transform(wiring.getClassLoader(),
wovenClass.getClassName(), wovenClass.getDefinedClass(),
wovenClass.getProtectionDomain(), wovenClass.getBytes());
if(result != null) {
wovenClass.setBytes(result);
wovenClass.getDynamicImports().addAll(transformer.getPackagesToAdd());