* @param manager
*/
@SuppressWarnings({ "deprecation", "unchecked" })
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager) throws RuntimeException {
try {
ClassPool cp = ClassPool.getDefault();
cp.insertClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader()));
cp.importPackage("org.zkoss.zul");
cp.importPackage("org.zkoss.zk.ui");
cp.importPackage("org.zkoss.cdi.util");
CtClass mainclas = cp.makeClass("org.zkoss.zkplus.cdi.ZKComponentProducerMethods");
final List<URL> l = getUrlsForCurrentClasspath();
Reflections reflections = new Reflections(
new ConfigurationBuilder().setUrls(l)
.setScanners(new FieldAnnotationsScanner()));
Set<Field> fields = reflections.getFieldsAnnotatedWith(ComponentId.class);
for (Iterator iterator2 = fields.iterator(); iterator2
.hasNext();) {
Field field = (Field) iterator2.next();
CtClass cls = cp.get(field.getType().getName());
String pckgName = cls.getPackageName();
if (Component.class.isAssignableFrom(field.getType()) || !pckgName.endsWith("zul.api")) {
addProducerMethod(field, mainclas);
}
}