Ask About Weld extension
xsalefter.xsalefter.yahoo.com Nov 2, 2010 12:36 AMHi.. All. I just get bit confused about weld extension and it's scanning behaviour:
- There is a progess step order for each extension? (for example, BeforeBeanDiscovery is throws before ProcessAnnotatedType, or AfterDeploymentValidation is the last extension events, etc)
- How to give default name to bean instance in weld? For example, I have a class
@View public class PersonDisplayUI extends JFrame {
private JButton buttonCreate;
}where View annotation is:
@Inherited
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
@Named
public @interface View {
String value() default "";
}But when I try to get the name, using
<X> void processBean(@Observes ProcessBean<X> pb, BeanManager beanManager) {
log.info("Process bean: " + pb.getBean().getName());
}the result is
750 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 750 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 766 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 766 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 766 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 766 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 782 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 782 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 782 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 797 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 797 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 797 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 797 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 813 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 813 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 813 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null 813 [main] INFO org.xsalefter.sweld.annotation.impl.SweldManager - Process bean: null
- How to get instance for each declared bean? For example, I want to get the instance of the PersonDisplayUI class in the extension code, get the property (buttonCreate), and register it with an event. Where I should do this? Should I use reflection manually, using getClass().newInstance() etc?
Thanks for your answer.