List of usage examples for org.springframework.beans.factory.support PropertiesBeanDefinitionReader registerBeanDefinitions
public int registerBeanDefinitions(Map<?, ?> map, @Nullable String prefix) throws BeansException
From source file:org.springframework.ejb.support.JndiEnvironmentBeanDefinitionReader.java
/** * Creates new JNDIBeanFactory/*from w ww . j a v a 2 s .c o m*/ * @param root likely to be "java:comp/env" */ public JndiEnvironmentBeanDefinitionReader(BeanDefinitionRegistry beanFactory, String root) throws BeansException { // We'll take everything from the NamingContext and dump it in a // Properties object, so that the superclass can efficiently manipulate it // after we've closed the context. HashMap m = new HashMap(); Context initCtx = null; try { initCtx = new InitialContext(); // Parameterize NamingEnumeration bindings = initCtx.listBindings(root); // Orion 1.5.2 doesn't seem to regard anything under a / // as a true subcontext, so we need to search all bindings // Not all that fast, but it doesn't matter while (bindings.hasMore()) { Binding binding = (Binding) bindings.next(); logger.debug("Name: " + binding.getName()); logger.debug("Type: " + binding.getClassName()); logger.debug("Value: " + binding.getObject()); m.put(binding.getName(), binding.getObject()); } bindings.close(); PropertiesBeanDefinitionReader propReader = new PropertiesBeanDefinitionReader(beanFactory); propReader.registerBeanDefinitions(m, BEANS_PREFIX); } catch (NamingException ex) { logger.debug("----- NO PROPERTIES FOUND " + ex); } finally { try { if (initCtx != null) { initCtx.close(); } } catch (NamingException ex) { // IGNORE OR THROW RTE? } } }