Seam 3 - retrieve all seam components in application context?

Didn't try myself, just a guess after reading 16.5. The Bean interface chapter of Weld documentation class ApplicationScopedBeans { @Inject BeanManager beanManager; public Set> getApplicationScopedBeans() { Set> allBeans = beanManager. GetBeans(Object. Class, new AnnotationLiteral() {}); Set> result = new HashSet>(); for(Bean bean : allBeans) { if(bean.getScope().

Equals(ApplicationScoped. Class)) { result. Add(bean); } } return result; } } UPDATE To obtain an instance of a Bean : public Object getApplicationScopedInstance(Bean bean) { CreationalContext ctx = beanManager.

CreateCreationalContext(bean); Context appCtx = beanManager. GetContext(ApplicationScoped. Class); return appCtx.

Get(bean, ctx); }.

Didn't try myself, just a guess after reading 16.5. The Bean interface chapter of Weld documentation class ApplicationScopedBeans { @Inject BeanManager beanManager; public Set> getApplicationScopedBeans() { Set> allBeans = beanManager. GetBeans(Object. Class, new AnnotationLiteral() {}); Set> result = new HashSet>(); for(Bean bean : allBeans) { if(bean.getScope().

Equals(ApplicationScoped. Class)) { result. Add(bean); } } return result; } } UPDATE To obtain an instance of a Bean: public Object getApplicationScopedInstance(Bean bean) { CreationalContext ctx = beanManager.

CreateCreationalContext(bean); Context appCtx = beanManager. GetContext(ApplicationScoped. Class); return appCtx.

Get(bean, ctx); }.

This returns Bean objects... – Fortega Jul 12 at 6:54.

If you want to call a method from a component in applicationContext or use a field in this, it's better that you define it as producer method or field and inject it where you want.

You would use getApplicationContext() to get the context, and then the getNames() to get all names of things that are application scope, and then you would use get()to retrieve them by name. What are you trying to do? From there you would have to use reflection to get them to the right type.. Context appContext = Contexts.

GetApplicationContext(); String names = appContext.getNames(); //Do whatever with them.. for(String s : names){ Object x = appContext. Get(name); // do something. }.

OP wants for Seam3 – Shervin Mar 21 at 8:51 Yup, that's exactly how I did it before, in SEAM 2... I'll remove the donwvote if you give me an answer for seam 3 :-p – Fortega Mar 21 at 10:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions