1 22 23 package org.jboss.spring.factory; 24 25 import org.springframework.beans.BeansException; 26 import org.springframework.beans.factory.support.DefaultListableBeanFactory; 27 import org.springframework.core.io.Resource; 28 29 32 public class NamedXmlBeanFactory extends DefaultListableBeanFactory 33 implements Nameable, Instantiable 34 { 35 36 private String defaultName; 37 private final NamedXmlBeanDefinitionReader reader = new NamedXmlBeanDefinitionReader(this); 38 39 42 public NamedXmlBeanFactory(String defaultName, Resource resource) throws BeansException 43 { 44 this.reader.loadBeanDefinitions(resource); 45 this.defaultName = defaultName; 46 } 47 48 public String getName() 49 { 50 String name = reader.getName() != null ? reader.getName() : defaultName; 51 if (name == null) 52 { 53 throw new IllegalArgumentException ("Bean factory JNDI name must be set!"); 54 } 55 return name; 56 } 57 58 public boolean doInstantiate() 59 { 60 return reader.doInstantiate(); 61 } 62 63 } 64 | Popular Tags |