Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Beans / BeansLocal getInstance( String name ) #673

Closed
pizzi80 opened this issue Feb 19, 2022 · 0 comments
Closed

Feature request: Beans / BeansLocal getInstance( String name ) #673

pizzi80 opened this issue Feb 19, 2022 · 0 comments

Comments

@pizzi80
Copy link
Contributor

pizzi80 commented Feb 19, 2022

Sometimes could be useful...

Seam / Deltaspike style

getInstance( String name ) 
getInstance( String name , boolean create )
public static <T> T getInstance(String name) {
  return getInstance(name,true);
}


public static <T> T getInstance(String name,boolean create) {
  BeanManager beanManager = getBeanManager();			  // get BeanManager
  Set<Bean<?>> beans = beanManager.getBeans(name);              // get all the Beans with name
  Bean<?> bean = beanManager.resolve(beans);			         // resolve the best candidate
  return (T)BeansLocal.getInstance(beanManager,bean,create);    // OmniFaces BeansLocal
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant