读书人

让Spring支持类库的一致部署和自动升级

发布时间: 2012-10-06 17:34:01 作者: rapoo

让Spring支持类库的统一部署和自动升级

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans> <bean id="jiopi" singleton="false" factory-method="accessControlPanel"/> <bean id="helloworld" singleton="false" factory-method="accessControlPanel"> <constructor-arg type="java.lang.String"><value>jiopi.ibean.helloworld.i</value></constructor-arg> <constructor-arg type="java.lang.String"><null/></constructor-arg> <constructor-arg type="java.lang.String"><value>org.jiopi.ibean.example.module.helloworld.HelloWorldImpl</value></constructor-arg> <constructor-arg type="java.lang.Class"><value>org.jiopi.ibean.example.blueprint.helloworld.HelloWorld</value></constructor-arg> <constructor-arg type="java.lang.Object[]"><list></list></constructor-arg> <property name="msg"><value>spring msg</value></property> </bean></beans>

?

//直接获取配置好的Bean,使用Spring二次装配HelloWorld hw = appContext.getBean("helloworld",HelloWorld.class);hw.helloWorld();//JIOPi隐含调用,默认构造函数HelloWorld jiopiHw = (HelloWorld) appContext.getBean("jiopi","jiopi.ibean.helloworld.i",null,"org.jiopi.ibean.example.module.helloworld.HelloWorldImpl", HelloWorld.class,new Object[]{});jiopiHw.helloWorld();//JIOPi隐含调用,使用带一个参数的构造函数HelloWorld jiopiHwMy = (HelloWorld) appContext.getBean("jiopi","jiopi.ibean.helloworld.i",null,"org.jiopi.ibean.example.module.helloworld.HelloWorldImpl", HelloWorld.class,new Object[]{"my msg"});jiopiHwMy.helloWorld();

?

?

总结

将JIOPi嵌入Spring,你既可以享受远程模块带来的优点

实现类无需部署在运行环境

实现类的更新后所有使用环境自动生效

可以存在同一功能的多个版本的远程服务

?

?

也可以像使用本地类库那样充分使用Spring的各种特性

?

而你也并不会因此而改变你的代码风格

读书人网 >软件架构设计

热点推荐