@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()) { // Separate key value pairs into object declarations and property assignment // so that all objects can be created up front //https://issues.apache.org/jira/browse/SHIRO-85 - need to use LinkedHashMaps here: Map<String, String> instanceMap = new LinkedHashMap<String, String>(); Map<String, String> propertyMap = new LinkedHashMap<String, String>(); for (Map.Entry<String, String> entry : kvPairs.entrySet()) { if (entry.getKey().indexOf('.') < 0 || entry.getKey().endsWith(".class")) { instanceMap.put(entry.getKey(), entry.getValue()); } else { propertyMap.put(entry.getKey(), entry.getValue()); } } // Create all instances for (Map.Entry<String, String> entry : instanceMap.entrySet()) { createNewInstance((Map<String, Object>) objects, entry.getKey(), entry.getValue()); } // Set all properties for (Map.Entry<String, String> entry : propertyMap.entrySet()) { applyProperty(entry.getKey(), entry.getValue(), objects); } } 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; } }