if(null == instanceMap) {
instanceMap= Maps.newHashMap();
}
IAnnotationFinder annotationFinder = configuration.getAnnotationFinder();
ITestObjectFactory objectFactory = configuration.getObjectFactory();
//
// Find all the new classes and their corresponding instances
//
Set<Class<?>> allClasses= cim.getClasses();
//very first pass is to find ObjectFactory, can't create anything else until then
if(objectFactory == null) {
objectFactory = new ObjectFactoryImpl();
outer:
for (Class cls : allClasses) {
try {
if (null != cls) {
for (Method m : cls.getMethods()) {
IAnnotation a = annotationFinder.findAnnotation(m,
org.testng.annotations.IObjectFactoryAnnotation.class);
if (null != a) {
if (!ITestObjectFactory.class.isAssignableFrom(m.getReturnType())) {
throw new TestNGException("Return type of " + m + " is not IObjectFactory");
}