1.XML配置
<?xml version="1.0"?>
<meta>
<entry name="ejb_server">
<attribute name="factory" value="org.jnp.inte易做图ces.NamingContextFactory" />
<attribute name="url" value="jnp://10.1.2.141:1099" />
<attribute name="uerid" value="a" />
<attribute name="password" value="a" />
</entry>
<entry name="db_pool">
<attribute name="poolurl" value="jdbc:oracle:thin:@192.168.8.54:1521:ora11g" />
<attribute name="driver" value="oracle.jdbc.driver.OracleDriver" />
<attribute name="poolSize" value="250" />
<attribute name="login" value="erp" />
<attribute name="password" value="123456" />
<entry name="trendcom" type="database">
<attribute name="poolurl" value="jdbc:oracle:thin:@192.168.8.54:1521:ora11g" />
<attribute name="driver" value="oracle.jdbc.driver.OracleDriver" />
<attribute name="poolSize" value="250" />
<attribute name="login" value="erp" />
<attribute name="password" value="123456" />
</entry>
</entry>
<entry name="db_manager">
<attribute name="mgrurl" value="java:/xasDB2Pool" />
<entry name="sql_definitions">
<attribute name="default" value="sql" />
</entry>
</entry>
<entry name="connector">
<attribute name="optimize" value="true" />
<attribute name="default" value="stateless" />
</entry>
<entry name="jms_server"><!-- ifengjofo830113 -->
<attribute name="context_factory" value="org.jnp.inte易做图ces.NamingContextFactory" />
<attribute name="url" value="10.1.2.141:1099" />
<attribute name="pkg_prefix" value="org.jboss.naming" />
</entry>
<entry name="email" type="system">
<attribute name="host" value="mail.trendcom.com.cn" />
<attribute name="mode" value="exServer" />
<attribute name="port" value="25" />
<attribute name="user" value="chen@trendcom.com.cn" />
<attribute name="password" value="evnyl0ng" />
<attribute name="from" value="chen@trendcom.com.cn" />
</entry>
</meta>
2.java读取
/**
*serviceName
*serviceName2 文件路径名称
*paramName
*/
public String getServiceParam(String serviceName, String serviceName2, String paramName) throws MetaException
{
EntryObject topEntry = getTopEntry();
EntryObject servEntry = topEntry.getChildEntry(serviceName);
EntryObject servEntry2 = servEntry.getChildEntry(serviceName2);
if (servEntry == null) {
throw new MetaFindException(serviceName + " is not found as a service meta entry");
}
if (servEntry2 == null) {
return getServiceParam(serviceName, paramName);
}
return servEntry2.getValue(paramName);
}
}
3.调用
String connUrl = SysInfoReader.instance().getServiceParam("db_pool", "default", "poolurl");
String dbDrv = SysInfoReader.instance().getServiceParam("db_pool", "default", "driver");
String dbLogin = SysInfoReader.instance().getServiceParam("db_pool", "default", "login");
String dbPw = SysInfoReader.instance().getServiceParam("db_pool", "default", "password");