Author: natalia
Date: Sun Oct 26 07:50:07 2008
New Revision: 708000
URL: http://svn.apache.org/viewvc?rev=708000&view=rev
Log:
Fixed a bug where XML-RPC Xindice client could only connect to a single Xindice server
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java
Modified: xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java?rev=708000&r1=707999&r2=708000&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java Sun Oct 26 07:50:07 2008
@@ -24,7 +24,6 @@
import org.apache.xindice.client.xmldb.CommonConfigurable;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
-
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.base.ErrorCodes;
@@ -32,6 +31,8 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
/**
* Implements XML:DB's <code>Database</code> interface using XML-RPC to communicate
@@ -107,11 +108,10 @@
*/
private static final String CONFORMANCE_LEVEL = "0";
-
/**
- * XML-RPC client used to communicate with the server
+ * Map contains XML_RPC clients for different hostname:port addresses
*/
- private XmlRpcClient client;
+ private Map clients = new HashMap();
/**
@@ -155,12 +155,12 @@
*
* @param hostPort of the Xindice XML-RPC server
* @return XML-RPC client connected to the Xindice server
- * @throws XMLDBException
+ * @throws XMLDBException if host or port information was incorrect and resulted in malformed URL
*/
private XmlRpcClient connect(String hostPort) throws XMLDBException {
synchronized (this) {
- if (client == null) {
+ if (!clients.containsKey(hostPort)) {
// Initialize XML-RPC static properties
XmlRpcClientConfigImpl cfg = new XmlRpcClientConfigImpl();
cfg.setEncoding("utf-8");
@@ -219,12 +219,14 @@
cfg.setBasicPassword(basicPassword);
}
- client = new XmlRpcClient();
+ XmlRpcClient client = new XmlRpcClient();
client.setConfig(cfg);
+
+ clients.put(hostPort, client);
}
}
- return client;
+ return (XmlRpcClient) clients.get(hostPort);
}
/**
@@ -243,7 +245,6 @@
* null if the database does not support authentication.
* @return A <code>Collection</code> instance for the requested collection or
* null if the collection could not be found.
- * @return The <code>Collection</code> instance
* @exception XMLDBException with expected error codes.<br />
* <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
* specific errors that occur.<br />
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.