/** * Creates a parent application context populated with system components configured to be aliased as Spring beans. * * @param classLoader the context classloader * @param properties any defined property values keyed by name * @return the parent application context */ private SCAApplicationContext createParentContext(ClassLoader classLoader, Map<String, Pair> properties) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); SCAApplicationContext parent = new SCAApplicationContext(); for (Map.Entry<String, Pair> entry : properties.entrySet()) { String name = entry.getKey(); Pair pair = entry.getValue(); parent.add(name, pair.getType(), pair.getSupplier()); } for (ApplicationContextListener listener : listeners) { listener.onCreate(parent); } return parent; } finally { Thread.currentThread().setContextClassLoader(old); } }
/** * Creates a parent application context populated with system components configured to be aliased as Spring beans. * * @param classLoader the context classloader * @param properties any defined property values keyed by name * @return the parent application context */ private SCAApplicationContext createParentContext(ClassLoader classLoader, Map<String, Pair> properties) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); SCAApplicationContext parent = new SCAApplicationContext(); for (Map.Entry<String, Pair> entry : properties.entrySet()) { String name = entry.getKey(); Pair pair = entry.getValue(); parent.add(name, pair.getType(), pair.getFactory()); } for (ApplicationContextListener listener : listeners) { listener.onCreate(parent); } return parent; } finally { Thread.currentThread().setContextClassLoader(old); } }
protected Map<String, Pair> createProperties(PhysicalSpringComponent springComponent) throws Fabric3Exception { List<PhysicalProperty> properties = springComponent.getProperties(); Map<String, Pair> values = new HashMap<>(); for (PhysicalProperty property : properties) { String name = property.getName(); if (property.getInstanceValue() != null) { Pair pair = new Pair(Object.class, property::getInstanceValue); values.put(name, pair); } else { Document document = property.getXmlValue(); String value = document.getElementsByTagName("value").item(0).getFirstChild().getNodeValue(); QName type = property.getType(); if (XSD_BOOLEAN.equals(type)) { Pair pair = new Pair(Boolean.class, () -> Boolean.valueOf(value)); values.put(name, pair); } else if (XSD_INT.equals(type)) { Pair pair = new Pair(Integer.class, () -> Boolean.valueOf(value)); values.put(name, pair); } else { Pair pair = new Pair(String.class, () -> value); values.put(name, pair); } } } return values; }
/** * Creates a parent application context populated with system components configured to be aliased as Spring beans. * * @param classLoader the context classloader * @param properties any defined property values keyed by name * @return the parent application context */ private SCAApplicationContext createParentContext(ClassLoader classLoader, Map<String, Pair> properties) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); SCAApplicationContext parent = new SCAApplicationContext(); for (Map.Entry<String, Pair> entry : properties.entrySet()) { String name = entry.getKey(); Pair pair = entry.getValue(); parent.add(name, pair.getType(), pair.getSupplier()); } for (ApplicationContextListener listener : listeners) { listener.onCreate(parent); } return parent; } finally { Thread.currentThread().setContextClassLoader(old); } }
protected Map<String, Pair> createProperties(PhysicalSpringComponent springComponent) throws Fabric3Exception { List<PhysicalProperty> properties = springComponent.getProperties(); Map<String, Pair> values = new HashMap<>(); for (PhysicalProperty property : properties) { String name = property.getName(); if (property.getInstanceValue() != null) { Pair pair = new Pair(Object.class, property::getInstanceValue); values.put(name, pair); } else { Document document = property.getXmlValue(); String value = document.getElementsByTagName("value").item(0).getFirstChild().getNodeValue(); QName type = property.getType(); if (XSD_BOOLEAN.equals(type)) { Pair pair = new Pair(Boolean.class, () -> Boolean.valueOf(value)); values.put(name, pair); } else if (XSD_INT.equals(type)) { Pair pair = new Pair(Integer.class, () -> Boolean.valueOf(value)); values.put(name, pair); } else { Pair pair = new Pair(String.class, () -> value); values.put(name, pair); } } } return values; }
protected Map<String, Pair> createProperties(SpringComponentDefinition definition) throws BuilderException { List<PhysicalPropertyDefinition> propertyDefinitions = definition.getPropertyDefinitions(); Map<String, Pair> values = new HashMap<String, Pair>(); for (PhysicalPropertyDefinition propertyDefinition : propertyDefinitions) { String name = propertyDefinition.getName(); Document document = propertyDefinition.getValue(); String value = document.getElementsByTagName("value").item(0).getFirstChild().getNodeValue(); QName type = propertyDefinition.getType(); if (XSD_BOOLEAN.equals(type)) { SingletonObjectFactory<Boolean> factory = new SingletonObjectFactory<Boolean>(Boolean.valueOf(value)); Pair pair = new Pair(Boolean.class, factory); values.put(name, pair); } else if (XSD_INT.equals(type)) { SingletonObjectFactory<Integer> factory = new SingletonObjectFactory<Integer>(Integer.valueOf(value)); Pair pair = new Pair(Integer.class, factory); values.put(name, pair); } else { SingletonObjectFactory<String> factory = new SingletonObjectFactory<String>(value); Pair pair = new Pair(String.class, factory); values.put(name, pair); } } return values; }