protected void loadVariableFromBeans(BeanFactory beanFactory){ Map<Variable,BeanDefinition> beans = beanFactory.getBeansWithDefinition(Variable.class); beans.putAll(beanFactory.getBeansWithDefinition(VariableWithContext.class)); for(Entry<Variable,BeanDefinition> entry : beans.entrySet()){ BeanDefinition bd = entry.getValue(); String name = bd.getName(); if(!Strings.isEmpty(name)){ Variable variable = entry.getKey(); Scope scope = null; if(variable instanceof ScopedVariable){ scope = ((ScopedVariable) variable).getScope(); } if(null == scope){ scope = defaultScope; } variables.put(name.toLowerCase(), new VariableDefinition(bd.getSource(), name, scope, variable)); } } }
String name = bd.getName(); if(Strings.isEmpty(name)) { Name na = plugin.getClass().getAnnotation(Name.class);
@Override public void postCreateBean(AppContext context, BeanFactory factory, BeanDefinition def, Object bean) throws Throwable { boolean exportMBean = def.isExportMBean(); Managed a = bean.getClass().getAnnotation(Managed.class); if(null != a) { exportMBean = true; } if(exportMBean) { String name = def.getMBeanName(); if(Strings.isEmpty(name)){ name = null == a ? null : a.name(); } if(Strings.isEmpty(name)) { if(!Strings.isEmpty(def.getId())) { name = def.getId(); }else if(!Strings.isEmpty(def.getName())){ name = def.getType().getName() + "#" + def.getName(); }else if(def.isPrimary()) { name = def.getType().getName(); }else { name = def.getType().getName() + "-[mbean-" + String.valueOf(counter++) + "]"; } } log.info("Export mbean '{}' of {}", name, def); exporter.export(name, bean); } }
throw new BeanDefinitionException("Found duplicated " + (proxy ? "proxy" : "bean") + " name '" + definition.getName() + "' for type '" + beanType.getName() + "' in resource : " + definition.getSource() + " with exists " + (proxy ? "proxy " : "bean ") + existsBeanDefinition);