vgritsenko 2004/01/28 19:18:43
Modified: src/blocks/xmldb/java/org/apache/cocoon/components/source/impl
XMLDBSourceFactory.java
Log:
Pass configuration parameters to the XML:DB driver instance
Revision Changes Path
1.6 +15 -9
cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSourceFactory.java
Index: XMLDBSourceFactory.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSourceFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLDBSourceFactory.java 5 Dec 2003 20:05:37 -0000 1.5
+++ XMLDBSourceFactory.java 29 Jan 2004 03:18:43 -0000 1.6
@@ -94,14 +94,14 @@
credentialMap = new HashMap();
- Configuration[] xmldbConfigs = conf.getChildren("driver");
- for (int i = 0; i < xmldbConfigs.length; i++) {
- String type = xmldbConfigs[i].getAttribute("type");
- String driver = xmldbConfigs[i].getAttribute("class");
+ Configuration[] drivers = conf.getChildren("driver");
+ for (int i = 0; i < drivers.length; i++) {
+ String type = drivers[i].getAttribute("type");
+ String driver = drivers[i].getAttribute("class");
SourceCredential credential = new SourceCredential(null, null);
- credential.setPrincipal(xmldbConfigs[i].getAttribute("user",
null));
- credential.setPassword(xmldbConfigs[i].getAttribute("password",
null));
+ credential.setPrincipal(drivers[i].getAttribute("user", null));
+ credential.setPassword(drivers[i].getAttribute("password",
null));
credentialMap.put(type, credential);
if (getLogger().isDebugEnabled()) {
@@ -109,8 +109,14 @@
}
try {
- Class c = Class.forName(driver);
- DatabaseManager.registerDatabase((Database)c.newInstance());
+ Database db = (Database)Class.forName(driver).newInstance();
+
+ Configuration[] params = drivers[i].getChildren();
+ for (int j = 0; j < params.length; j++) {
+ db.setProperty(params[j].getName(),
params[j].getValue());
+ }
+
+ DatabaseManager.registerDatabase(db);
} catch (XMLDBException xde) {
String error = "Unable to connect to the XMLDB database.
Error "