bamboo-spring-ext 1.0.1 版。
google code地址:
http://code.google.com/p/bamboo-spring-ext/
去年项目中对Spring的简单封装,实现bean零配置。
设计原因和目的:
1) 简化Spring下业务 bean 的集成方式,减少不必要配置;
2) 支持无Annotation的纯 Java POJO,便于 POJO 进行不同形式的的集成;
3) 对遗留系统以最简单的方式和Spring集成,以使用Spring的AOP容器等功能;
现有时间将其打包,写点userguide,分享出来。 后续计划将其他微小但实用的特性也打包进来。
*bamboo-spring-ext* allow you to create a java object automatically and dynamically binded with Spring container without need to config bean. Spring AOP also worked with those beans.
Code example as following:
import org.bamboo.spring.*;
//default scope is prototype
OrderService orderService = (OrderService) BeanFactory.createBean(OrderService.class);
orderService.deleteOrder("AA001");
//singleton demo:
OrderService orderService = (OrderService) BeanFactory.createBean(OrderService.class, true);
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<!-- no <bean/> config is needed by bamboo-spring-ext tool. -->
<!-- Below is a demo for AOP also works with those bean not configed above. -->
<bean id="logAdvisor" class="org.bamboo.spring.demo.LogAdvisor" />
..... see userguide and test package for details.
引用
说明:
1, BeanFactory.createBean(OrderService.class) 相当于动态注册了(无需配置)
<bean id="org.bamboo.spring.test.OrderService" class="org.bamboo.spring.test.OrderService"/>
2, 容器中的AOP Advisor,Interceptor 等能自动对这些Bean进行proxy代理, 达到与配置的bean 同样的效果。