package com.alvazan.orm.layer0.base;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alvazan.orm.api.base.anno.NoSqlEmbeddable;
import com.alvazan.orm.api.base.anno.NoSqlEntity;
import com.alvazan.orm.impl.meta.scan.ScannerForClass;
import com.impetus.annovention.listener.ClassAnnotationDiscoveryListener;

public class MyClassAnnotationDiscoveryListener implements
		ClassAnnotationDiscoveryListener {

	private static final Logger log = LoggerFactory.getLogger(MyClassAnnotationDiscoveryListener.class);

	@Inject
	private ScannerForClass inspectorClass;

	private ClassLoader classLoader; 

	@Override
	public String[] supportedAnnotations() {
		return new String[] {NoSqlEntity.class.getName(), NoSqlEmbeddable.class.getName()};
	}

	@Override
	public void discovered(String clazzName, String annotation) {
		log.debug("class="+clazzName+" anno="+annotation);
		try {
			Class<?> clazz = classLoader.loadClass(clazzName);
			
			scanClass(clazz);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}
	}

	public void scanClass(Class<?> clazz) {
		inspectorClass.addClass(clazz);
	}

	public void setClassLoader(ClassLoader cl) {
		this.classLoader = cl;
	}

}

@@ -1158,16 +1158,26 @@
 azz) %7B%0D%0A
+%09%09try %7B%0D%0A%09
 %09%09inspec
@@ -1203,16 +1203,144 @@
 lazz);%0D%0A
+%09%09%7D catch(RuntimeException e) %7B%0D%0A%09%09%09throw new RuntimeException(%22Failure parsing class(see chained exception)=%22+clazz, e);%0D%0A%09%09%7D%0D%0A
 %09%7D%0D%0A%0D%0A%09p

put another fix in