com.bstek.dorado.core
public abstract class SpringContextSupport extends ContextSupport
在默认的实现机制中,Dorado使用的核心服务都是配置在Spring的配置文件中的,并且所有的Bean都被冠以dorado.前缀。
例如:
<bean id="dorado.xmlDocumentBuilder" ....>
如果用户需要以自己的Bean替换掉某服务的默认实现类,那么他应当在其Spring配置文件中配置同名的Bean,
且使用不同的配置。此时用户自行定义的Bean将会覆盖Dorado默认的配置。
注意:相同名称的Bean的定义不能出现在同一个配置文件中。后装载的配置文件中的Bean将会覆盖先前装载的配置文件中的同名的Bean。
参考/com/bstek/dorado/core/configure.properties中的core.configLocation和core.
extensionConfigLocation参数,
dorado总是先尝试装载core.configLocation中定义的配置文件,然后在装载core.
extensionConfigLocation中定义的文件。
需要注意的是,当我们通过Context
来获取某个服务类时,并不需要指定Bean的前缀。
例如当我们试图获取上面提到的xmlDocumentBuilder
服务时,相应的代码应为:
context.getServiceBean("xmlDocumentBuilder");Dorado将自动根据配置查找名为dorado.xmlDocumentBuilder的Bean。
Context
,
ApplicationContext
Constructor and Description |
---|
SpringContextSupport() |
Modifier and Type | Method and Description |
---|---|
abstract org.springframework.context.ApplicationContext |
getApplicationContext() |
java.lang.Object |
getServiceBean(java.lang.String name)
获取某个核心服务类的实例。 在目前的实现方式中,服务类都是注册在Spring的配置文件中的。
|
getClassLoader, getResource, getResourceLoader, getResources
attachToThreadLocal, dettachFromThreadLocal, getAttribute, getAttribute, getCurrent, removeAttribute, removeAttribute, setAttribute, setAttribute, setFailSafeContext
public abstract org.springframework.context.ApplicationContext getApplicationContext() throws java.lang.Exception
java.lang.Exception
public java.lang.Object getServiceBean(java.lang.String name) throws java.lang.Exception
getServiceBean
in class Context
name
- 服务名称java.lang.Exception
Copyright © 2001-2011 www.BSTEK.com All Rights Reserved.