[quote="AliKevin"][b] Apache James 3.x之后采用了Spring框架,配置文件的名称和组织方式与2.x发生了较大的变化,本系列将介绍3.x版本中的主要配置文件。这篇主要介绍Spring-server.xml文件[/b][/quote]
[b]一、概述[/b]
spring-server.xml文件是James 3.x 所有配置文件的切入文件,James3.x主类(org.apache.james.container.spring.Main.java)启动时候会在init方法中载入该配置文件,如下:
public void init(DaemonContext arg0) throws Exception {
[color=red]context = new JamesServerApplicationContext(new String[] { "META-INF/org/apache/james/spring-server.xml" });[/color]
context.registerShutdownHook();
context.start();
}
[b]二、spring-server.xml 介绍[/b]
附件是spring-server.xml的完整内容,为方便介绍我们将配置文件以一个片段一个片段的介绍。
[list][*][b]打开Spring的注释功能[/b][/list]
[list][*][b]配置JAMES特定配置文件的加载[/b][/list]
[color=indigo][说明:
ConfigurationBeanFactoryPostProcessor实现了org.springframework.beans.factory.config.BeanFactoryPostProcessor接口,实现此接口的Bean,可以在BeanFactory完成依赖注入后进行一些后继处理动作,ConfigurationBeanFactoryPostProcessor就是在完成依赖注入之后将JAMES提供的具体Repository配置文件进行加载。ConfigurationBeanFactoryPostProcessor的beans
属性列表配置的value必须是James的classpath下面的配置文件的文件名,ConfigurationBeanFactoryPostProcessor会根据配置的value在classpath中应用org.apache.commons.configuration.XMLConfiguration类进行配置文件加载,然后应用Spring的BeanDefinitionBuilder和BeanDefinitionRegistry将配置的类进行实例化并注册到Spring context中.
][/color]
[b]三、结束[/b]
[b]一、概述[/b]
spring-server.xml文件是James 3.x 所有配置文件的切入文件,James3.x主类(org.apache.james.container.spring.Main.java)启动时候会在init方法中载入该配置文件,如下:
public void init(DaemonContext arg0) throws Exception {
[color=red]context = new JamesServerApplicationContext(new String[] { "META-INF/org/apache/james/spring-server.xml" });[/color]
context.registerShutdownHook();
context.start();
}
[b]二、spring-server.xml 介绍[/b]
附件是spring-server.xml的完整内容,为方便介绍我们将配置文件以一个片段一个片段的介绍。
[list][*][b]打开Spring的注释功能[/b][/list]
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
<property name="order" value="3" />
</bean>
[list][*][b]配置JAMES特定配置文件的加载[/b][/list]
[color=indigo][说明:
ConfigurationBeanFactoryPostProcessor实现了org.springframework.beans.factory.config.BeanFactoryPostProcessor接口,实现此接口的Bean,可以在BeanFactory完成依赖注入后进行一些后继处理动作,ConfigurationBeanFactoryPostProcessor就是在完成依赖注入之后将JAMES提供的具体Repository配置文件进行加载。ConfigurationBeanFactoryPostProcessor的beans
属性列表配置的value必须是James的classpath下面的配置文件的文件名,ConfigurationBeanFactoryPostProcessor会根据配置的value在classpath中应用org.apache.commons.configuration.XMLConfiguration类进行配置文件加载,然后应用Spring的BeanDefinitionBuilder和BeanDefinitionRegistry将配置的类进行实例化并注册到Spring context中.
][/color]
<bean class="org.apache.james.container.spring.bean.factorypostprocessor.ConfigurationBeanFactoryPostProcessor">
<property name="beans">
<map>
<!-- User Repository-->
<entry>
<key>
<!-- 对应 usersrepository.xml 文件配置 -->
<value>usersrepository</value>
</key>
<!-- no alias needed -->
<value></value>
</entry>
<!-- Recipient Rewrite Table-->
<entry>
<key>
<!--对应 recipientrewritetable.xml 文件配置 -->
<value>recipientrewritetable</value>
</key>
<!-- no alias needed -->
<value></value>
</entry>
<!-- Domain List -->
<entry>
<key>
<!--对应 domainlist.xml 文件配置-->
<value>domainlist</value>
</key>
<!-- no alias needed -->
<value></value>
</entry>
<entry>
<key>
<!--对应 usersrepository23.xml 文件配置 -->
<value>usersrepository23</value>
</key>
<!-- no alias needed -->
<value></value>
</entry>
</map>
</property>
</bean>
[b]三、结束[/b]