`
AliKevin2011
  • 浏览: 116909 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

JAMES V3 配置文件系列之spring-server.xml

阅读更多
AliKevin 写道
       Apache James 3.x之后采用了Spring框架,配置文件的名称和组织方式与2.x发生了较大的变化,本系列将介绍3.x版本中的主要配置文件。这篇主要介绍Spring-server.xml文件


一、概述
      spring-server.xml文件是James 3.x 所有配置文件的切入文件,James3.x主类(org.apache.james.container.spring.Main.java)启动时候会在init方法中载入该配置文件,如下:

     public void init(DaemonContext arg0) throws Exception {
         context = new JamesServerApplicationContext(new String[] {    "META-INF/org/apache/james/spring-server.xml" });
        context.registerShutdownHook();
        context.start();
     }
二、spring-server.xml 介绍
    附件是spring-server.xml的完整内容,为方便介绍我们将配置文件以一个片段一个片段的介绍。

  • 打开Spring的注释功能
  <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
 <property name="order" value="3" />
</bean>



  • 配置JAMES特定配置文件的加载
[说明:
      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中.
]

<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>


三、结束

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics