1 16 17 package org.springframework.context.support; 18 19 import java.util.Locale ; 20 21 import org.springframework.beans.BeansException; 22 import org.springframework.beans.MutablePropertyValues; 23 import org.springframework.beans.factory.support.RootBeanDefinition; 24 import org.springframework.context.ApplicationContext; 25 26 39 public class StaticApplicationContext extends GenericApplicationContext { 40 41 private final StaticMessageSource staticMessageSource; 42 43 44 51 public StaticApplicationContext() throws BeansException { 52 this(null); 53 } 54 55 62 public StaticApplicationContext(ApplicationContext parent) throws BeansException { 63 super(parent); 64 65 this.staticMessageSource = new StaticMessageSource(); 67 getBeanFactory().registerSingleton(MESSAGE_SOURCE_BEAN_NAME, this.staticMessageSource); 68 } 69 70 75 public StaticMessageSource getStaticMessageSource() { 76 return this.staticMessageSource; 77 } 78 79 80 85 public void registerSingleton(String name, Class clazz) throws BeansException { 86 getDefaultListableBeanFactory().registerBeanDefinition(name, new RootBeanDefinition(clazz)); 87 } 88 89 94 public void registerSingleton(String name, Class clazz, MutablePropertyValues pvs) throws BeansException { 95 getDefaultListableBeanFactory().registerBeanDefinition(name, new RootBeanDefinition(clazz, pvs)); 96 } 97 98 103 public void registerPrototype(String name, Class clazz) throws BeansException { 104 getDefaultListableBeanFactory().registerBeanDefinition(name, new RootBeanDefinition(clazz, false)); 105 } 106 107 112 public void registerPrototype(String name, Class clazz, MutablePropertyValues pvs) throws BeansException { 113 getDefaultListableBeanFactory().registerBeanDefinition(name, new RootBeanDefinition(clazz, pvs, false)); 114 } 115 116 123 public void addMessage(String code, Locale locale, String defaultMessage) { 124 getStaticMessageSource().addMessage(code, locale, defaultMessage); 125 } 126 127 } 128 | Popular Tags |