} else {
// create it and put it back in the weavingAdaptors map but avoid any kind of instantiation
// within the synchronized block
- ClassLoaderWeavingAdaptor weavingAdaptor = new ClassLoaderWeavingAdaptor(loader, weavingContext);
+ ClassLoaderWeavingAdaptor weavingAdaptor = new ClassLoaderWeavingAdaptor();
adaptor = new ExplicitlyInitializedClassLoaderWeavingAdaptor(weavingAdaptor);
weavingAdaptors.put(loader, adaptor);
}
private List m_aspectIncludeStartsWith = new ArrayList();
private StringBuffer namespace;
- private ClassLoader classLoader;
private IWeavingContext weavingContext;
private static Trace trace = TraceFactory.getTraceFactory().getTrace(ClassLoaderWeavingAdaptor.class);
- public ClassLoaderWeavingAdaptor(final ClassLoader loader, IWeavingContext wContext) {
+ public ClassLoaderWeavingAdaptor() {
super();
if (trace.isTraceEnabled()) trace.enter("<init>",this);
- this.classLoader = loader;
- this.weavingContext = wContext;
+ if (trace.isTraceEnabled()) trace.exit("<init>");
+ }
+
+ /**
+ * We don't need a reference to the class loader and using it during
+ * construction can cause problems with recursion. It also makes sense
+ * to supply the weaving context during initialization to.
+ * @deprecated
+ */
+ public ClassLoaderWeavingAdaptor(final ClassLoader deprecatedLoader, final IWeavingContext deprecatedContext) {
+ super();
+ if (trace.isTraceEnabled()) trace.enter("<init>",this,new Object[] { deprecatedLoader, deprecatedContext });
if (trace.isTraceEnabled()) trace.exit("<init>");
}
- protected void initialize (final ClassLoader deprecatedLoader, IWeavingContext deprecatedContext) {
+ protected void initialize (final ClassLoader classLoader, IWeavingContext context) {
//super(null);// at this stage we don't have yet a generatedClassHandler to define to the VM the closures
if (initialized) return;
+ if (trace.isTraceEnabled()) trace.enter("initialize",this,new Object[] { classLoader, context });
+
+ this.weavingContext = context;
if (weavingContext == null) {
weavingContext = new DefaultWeavingContext(classLoader);
}
List definitions = parseDefinitions(classLoader);
if (!enabled) {
+ if (trace.isTraceEnabled()) trace.exit("initialize",enabled);
return;
}
}
initialized = true;
+ if (trace.isTraceEnabled()) trace.exit("initialize",enabled);
}
/**
};
- ClassLoaderWeavingAdaptor clwAdaptor = new ClassLoaderWeavingAdaptor(this,weavingContext);
+ ClassLoaderWeavingAdaptor clwAdaptor = new ClassLoaderWeavingAdaptor();
initializingAdaptor = true;
clwAdaptor.initialize(this,weavingContext);
initializingAdaptor = false;
public void testClassLoaderWeavingAdaptor() {
ClassLoader loader = new URLClassLoader(new URL[] {}, null);
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,null);
}
public void testGetNamespace() {
ClassLoader loader = new URLClassLoader(new URL[] {}, null);
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,null);
String namespace = adaptor.getNamespace();
assertEquals("Namespace should be empty","",namespace);
}
public void testGeneratedClassesExistFor() {
ClassLoader loader = new URLClassLoader(new URL[] {}, null);
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,null);
boolean exist = adaptor.generatedClassesExistFor("Junk");
assertFalse("There should be no generated classes",exist);
}
public void testFlushGeneratedClasses() {
ClassLoader loader = new URLClassLoader(new URL[] {}, null);
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,null);
adaptor.flushGeneratedClasses();
boolean exist = adaptor.generatedClassesExistFor("Junk");
assertFalse("There should be no generated classes",exist);
public void testWeavingContext() {
URLClassLoader loader = new URLClassLoader(new URL[] {},null);
IWeavingContext context = new TestWeavingContext(loader);
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,context);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,context);
}
public void testGetResources() {
}
};
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,context);
- adaptor.initialize(null,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,context);
assertTrue("IWeavingContext not called",called);
}
}
};
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,context);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
try {
- adaptor.initialize(null,null);
+ adaptor.initialize(loader,context);
}
catch (UnsupportedOperationException ex) {
fail("IWeavingContect.getBundleIdFromURL() is deprecated");
}
};
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,context);
- adaptor.initialize(null,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,context);
assertTrue("IWeavingContext not called",called);
}
}
};
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,context);
- adaptor.initialize(null,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,context);
assertTrue("IWeavingContext not called",called);
}
}
};
- ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor(loader,context);
- adaptor.initialize(null,null);
+ ClassLoaderWeavingAdaptor adaptor = new ClassLoaderWeavingAdaptor();
+ adaptor.initialize(loader,context);
assertTrue("IWeavingContext not called",called);
}