spring app-context configuration file



<!--
We can see that the configuration file's root element is <beans>, 
this tells us every element in the configuration file is a bean. 
 -->
<!--
Infact most of spring jar have 2 files: 
META-INF/spring.handlers and META-INF/spring.schemas. 
spring.handler maps to xmlns:xxx
spring.schemas maps to xsi:schemaLocation
1) spring.handlers maps the bean-definition in app-context configuration 
file to the handler-java-class, e.g. if we use <jee:xxxx /> in application-context 
file, according spring.handlers in org.springframework.context.jar, a handler 
called org.springframework.ejb.config.JeeNamespaceHandler 
will handle the parsing. Following is the spring.handlers content:
http\://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler
http\://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler
http\://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler
http\://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNamespaceHandler
http\://www.springframework.org/schema/cache=org.springframework.cache.config.CacheNamespaceHandler
2) spring.schemas used for defining the principles of XML, 
as we know xsd file is used to descripe a xml schema, the content 
of spring.schemas is a list of xsd file as following. 
Sure of that these xsd files can be found in spring jars. 
http\://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd
http\://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd
http\://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd
http\://www.springframework.org/schema/jee/spring-jee-3.1.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd
http\://www.springframework.org/schema/jee/spring-jee-3.2.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd
http\://www.springframework.org/schema/jee/spring-jee-4.0.xsd=org/springframework/ejb/config/spring-jee-4.0.xsd
http\://www.springframework.org/schema/jee/spring-jee-4.1.xsd=org/springframework/ejb/config/spring-jee-4.1.xsd
http\://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-4.1.xsd
 -->
<beans xmlns="http://www.springframework.org/schema/beans" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:aop="http://www.springframework.org/schema/aop"
              xmlns:tx="http://www.springframework.org/schema/tx" 
              xmlns:context="http://www.springframework.org/schema/context"
              xmlns:mvc="http://www.springframework.org/schema/mvc" 
              xmlns:task="http://www.springframework.org/schema/task" 
              xmlns:jee="http://www.springframework.org/schema/jee"
              xsi:schemaLocation="
                  http://www.springframework.org/schema/beans
                  http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
                  http://www.springframework.org/schema/tx
                  http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
                  http://www.springframework.org/schema/aop
                  http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
                  http://www.springframework.org/schema/context
                  http://www.springframework.org/schema/context/spring-context-4.1.xsd
                  http://www.springframework.org/schema/mvc
                  http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
                  http://www.springframework.org/schema/task
                  http://www.springframework.org/schema/task/spring-task-4.1.xsd
                  http://www.springframework.org/schema/jee
                  http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
                  ">


    <!--
    This bean is used for looking jndi objects(sure u should know what is jndi object). 
    Assume there is a data-source called ds-dev-mysql, use jee:jndi-lookup like this.
    if adding attribute "resource-ref=true", no need adding java:comp/env as spring
    will add it automatically. 
    Here it's necessary to think about how the DB connection pool works,will it be 
    handled on spring side? which strategies there are and how they work. Give some
    topics here: Servlet-Container/DBCP/C3P0
    -->
    <jee:jndi-lookup id="ds-dev-mysql" 
                                 jndi-name="java:comp/env/jdbc/ds-dev-mysql" 
                                 expected-type="javax.sql.dataSource"></jee:jndi-lookup>
    <!-- and sure we can also define a bean directly using JndiObjectFactoryBean -->
    <bean id="ds-dev-mysql-byFcty" 
                class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:comp/env/jdbc/ds-dev-mysql" />
    </bean>
    
</beans>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值