这样情况如何IoC
//PropertySet是里面可能做了一个map,通过key的值对应去初始一些东东。PropertySet别人的类本人要用到。
PropertySet propertySet = new PropertySet();
propertySet.setProperty("Server",server);
propertySet.setProperty("Instance",service);
propertySet.setProperty("user",user);
propertySet.setProperty("Password",new String(passwd));
还有这种情况:
/***LicenseProductCode.LicenseProductCo是个接口static变量返回一个int型,LicenseProductCode是接口***/
propertySet.initialize(LicenseProductCode.LicenseProductCodeEngine);
//原型propertySet.initialize(int LicenseProductCode.LicenseProductCodeEngine);
这样的情况如何IoC ?象我拿的是别人的中间件做二次性开发用spring合适吗?本人现在有点迷茫,有没有那个兄弟用到esri的这个东东,本人msn : sesamejie@hotmail.com
高手请教!
问题点数:50、回复次数:3Top
1 楼Saro(这也不是江水,这是二十年流不尽的英雄血。)回复于 2006-03-20 11:41:30 得分 0
Spring是很灵活的。写一个Factory类就成,:
public class PsFactory extends AbstractFactoryBean {
protected Object createInstance() throws Exception {
PropertySet ps=new PropertySet();
for (Iterator it = map.keySet().iterator(); it.hasNext();) {
String key = (String)it.next();
ps.setProperty(key,map.get(key));
}
return ps;
}
private Map map;
public void setMap(Map map) {
this.map = map;
}
public Class getObjectType() {
return PropertySet.class;
}
}
"是个接口static变量返回一个int型"
怎么象绕口令似的..................Top
2 楼sesameTang(芝麻酱)回复于 2006-03-21 10:10:47 得分 0
很感谢!三天还没有人答复,我会把分全给你。这样我不是要自己写很多类。不太爽,有没有直接通过xxx.xml注入的。
"是个接口static变量返回一个int型"
怎么象绕口令似的..................
呵呵。是我表达不清楚么?看原型:
public interface LicenseProductCode extends Serializable
-----------------------
Field Summary
-----------------------
static int LicenseProductCodeArcEditor
static int LicenseProductCodeArcInfo
static int LicenseProductCodeArcServer
static int LicenseProductCodeArcView
static int LicenseProductCodeEngine
static int LicenseProductCodeEngineGeoDB
--------------------------Top
3 楼Saro(这也不是江水,这是二十年流不尽的英雄血。)回复于 2006-03-21 11:14:23 得分 50
那没办法啊,你那个PropertySet又不是标准的java bean,你必须写个类告诉Spring容器如何初始化bean。你看看PropertySet暴露一个map或properties属性没有。Top




