@SuppressWarnings({"unchecked"}) public Map<String, ?> buildObjects(Map<String, String> kvPairs) { if (kvPairs != null && !kvPairs.isEmpty()) { BeanConfigurationProcessor processor = new BeanConfigurationProcessor(); for (Map.Entry<String, String> entry : kvPairs.entrySet()) { String lhs = entry.getKey(); String rhs = interpolator.interpolate(entry.getValue()); String beanId = parseBeanId(lhs); if (beanId != null) { //a beanId could be parsed, so the line is a bean instance definition processor.add(new InstantiationStatement(beanId, rhs)); } else { //the line must be a property configuration processor.add(new AssignmentStatement(lhs, rhs)); } } processor.execute(); } //SHIRO-413: init method must be called for constructed objects that are Initializable LifecycleUtils.init(objects.values()); return objects; }
@Override protected Object doExecute() { String beanName = this.lhs; createNewInstance(objects, beanName, this.rhs); Object instantiated = objects.get(beanName); setBean(instantiated); //also ensure the instantiated bean has access to the event bus or is subscribed to events if necessary: //Note: because events are being enabled on this bean here (before the instantiated event below is //triggered), beans can react to their own instantiation events. enableEventsIfNecessary(instantiated, beanName); BeanEvent event = new InstantiatedBeanEvent(beanName, instantiated, Collections.unmodifiableMap(objects)); eventBus.publish(event); return instantiated; } }
@SuppressWarnings({"unchecked"}) public Map<String, ?> buildObjects(Map<String, String> kvPairs) { if (kvPairs != null && !kvPairs.isEmpty()) { BeanConfigurationProcessor processor = new BeanConfigurationProcessor(); for (Map.Entry<String, String> entry : kvPairs.entrySet()) { String lhs = entry.getKey(); String rhs = interpolator.interpolate(entry.getValue()); String beanId = parseBeanId(lhs); if (beanId != null) { //a beanId could be parsed, so the line is a bean instance definition processor.add(new InstantiationStatement(beanId, rhs)); } else { //the line must be a property configuration processor.add(new AssignmentStatement(lhs, rhs)); } } processor.execute(); } //SHIRO-413: init method must be called for constructed objects that are Initializable LifecycleUtils.init(objects.values()); return objects; }
/** * Returns true if all configuration statements have been executed. * @return true if all configuration statements have been executed. */ public boolean isExecuted() { if (instantiationStatement != null && !instantiationStatement.isExecuted()) { return false; } for (AssignmentStatement as : assignments) { if (!as.isExecuted()) { return false; } } return true; } }
@Override protected Object doExecute() { String beanName = this.lhs; createNewInstance(objects, beanName, this.rhs); Object instantiated = objects.get(beanName); setBean(instantiated); //also ensure the instantiated bean has access to the event bus or is subscribed to events if necessary: //Note: because events are being enabled on this bean here (before the instantiated event below is //triggered), beans can react to their own instantiation events. enableEventsIfNecessary(instantiated, beanName); BeanEvent event = new InstantiatedBeanEvent(beanName, instantiated, Collections.unmodifiableMap(objects)); eventBus.publish(event); return instantiated; } }
private BeanConfiguration(InstantiationStatement statement) { statement.setBeanConfiguration(this); this.instantiationStatement = statement; this.beanName = statement.lhs; }
/** * Returns true if all configuration statements have been executed. * @return true if all configuration statements have been executed. */ public boolean isExecuted() { if (instantiationStatement != null && !instantiationStatement.isExecuted()) { return false; } for (AssignmentStatement as : assignments) { if (!as.isExecuted()) { return false; } } return true; } }
private BeanConfiguration(InstantiationStatement statement) { statement.setBeanConfiguration(this); this.instantiationStatement = statement; this.beanName = statement.lhs; }