Seam - list of all components

I would like to get a list of all the components so that I can process them. Is this possible, if so, how can I do this? I do not believe that I can observe all postCreate events, as this is just an exact match, not a regular expression.

@Observer ("org.jboss.seam.postCreate.")

You can observe only those events, not *, because they are placed on the map, where the key is a string.

Any ideas?

Walter

+3
source share
1 answer

As said

I would like to get a list of all the components

, , Seam .

  • < _ > .component

,

/**
  * Metamodel class for component classes
  *
  * Similar to org.springframework.beans.factory.config.BeanDefinition used by Spring
  */ 
org.jboss.seam.Component

Context context = Contexts.getApplicationContext();
for (String name: context.getNames()) {
    Object object = context.get(name);
    if(object instanceof org.jboss.seam.Component) {
        Component component = (Component) object;

        System.out.println(component.getName());
        System.out.println(component.getType());
        System.out.println(component.getScope());
        System.out.println(component.getTimeout());
        System.out.println(component.isStartup());
        System.out.println(component.isSynchronize());
    }
}

,

Object object = Component.getInstance(component.getName());
+3

Source: https://habr.com/ru/post/1745534/


All Articles