* @throws IllegalArgumentException if unsupported context specified
*/
public static IBean getBean(String name, IModelElement context) {
if (context instanceof IBeansConfig) {
IBeansConfig config = (IBeansConfig) context;
IBean bean = config.getBean(name);
if (bean == null) {
IBeanAlias alias = config.getAlias(name);
if (alias != null) {
bean = config.getBean(alias.getBeanName());
}
}
if (bean == null) {
for (IBeansComponent component : config.getComponents()) {
bean = getBean(name, component);
if (bean != null) {
return bean;
}
}
}
return bean;
}
else if (context instanceof IBeansConfigSet) {
IBeansConfigSet configSet = (IBeansConfigSet) context;
IBean bean = configSet.getBean(name);
if (bean == null) {
IBeanAlias alias = configSet.getAlias(name);
if (alias != null) {
bean = configSet.getBean(alias.getBeanName());
}