Spring 基础
1. beanfactory是最基本的 spring容器,也是applicationContext的祖先类2. beanfactory 配置文件,可以是xml,也可以是其他,可以是文件系统的资源,也可以是输入流,或者 servlet上下文资源
3. beanfactory的类,可以设置属性,也可以设置以带参数的构造函数 <constructor-arg>Hello!</construtor-arg>
4. a. 演出者(Performer),
b. 观众(Audience实现拍手,要求退票,关手机,坐下),
c. 事件监听(AudienceAdivce,实现方法前后,需要一个Audience实例)
d. 被监听方法发现者(Regex...Advisor, 告诉什么方法发生时,执行监听事件,所以需要有一个Adivce属性)
Performer.perform -> 被 Advisor 发现 -> 执行Advice的before/after... -> 执行 audience 的鼓掌
由此可知, Performer与audience, 在代码里,互不包含,或者说,Performer不知世界上,还有audience这类东西,audience亦然,所谓解藕。 5. 数据访问对象: JpaTransactionManager -> entityManagerFactory -> BasicDataSource -> jdbc连接参数 6.Web app loaded - > 触发 web.xml的spring...ContextLoaderListener
-> 用 web.xml中的param :contextConfigLocation,创建 ConfigurableWebApplicationContext
创建完了,放三个地方:
WebLoader.context
servletContext.attribute[WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE]
currentContextPerThread.put(Thread.currentThread().getContextClassLoader())
那什么时候用 ? 7. 指示com.jatools下面的类,需要spring来管理[code] <context:annotation-config />
<context:component-scan base-package="com.jatools" />[/code] 8. 让spring来创建 action,
a. 添加 struts_spring_plugin.jar到lib
b. 添加以下属性到 struts.xml[code] <constant name="struts.objectFactory" value="spring" />[/code]
页:
[1]