After more investigation I found out that the problem is eventually in the
XmlDb API.

Xindice wants to register three databases: "xindice, xindice-embed,
xindice-corba".  That's the value the getName method returns.  The
DatabaseManager takes this name as a key for the hashtable.  Consequently one
database object is registered with one single key.

When I want to gain access to a collection I give "xindice-embed" as part of
the URI.  Since the DatabaseManager has not record with this key (only with
"xindice, xindice-embed, xindice-corba") it returns null. :-(

The solution:
- define the format of the getName method in the case of multiple
implementations (e.g. the names must be separated by a ',' or a space)
- when registring a database, split the name according to the separator and
store one instance per separator in the hashtable.
- when deregistring a database, go through all the keys and remove the instance
from the hashtable.

here the code:

   public static void registerDatabase (Database database) throws
XMLDBException {
      if ((database.getName() == null) || (database.getName().equals(""))) {
         throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
      }

      StringTokenizer st = new StringTokenizer(database.getName(), ",");
      while (st.hasMoreTokens()) {
         String token = st.nextToken();
         databases.put(token.trim(), database);
      }
   }

   public static void deregisterDatabase (Database database) 
         throws XMLDBException {
      StringTokenizer st = new StringTokenizer(database.getName(), ",");
      while (st.hasMoreTokens()) {
         String token = st.nextToken();
         databases.remove(token.trim());
      }
   }

Of course you can choose another separator than ',' and check is a database is
already registered.

-Vladimir

--
Vladimir Bossicard
www.bossicard.com
----------------------------------------------------------------------
Post a message:         mailto:[EMAIL PROTECTED]
Unsubscribe:            mailto:[EMAIL PROTECTED]
Contact administrator:  mailto:[EMAIL PROTECTED]
Read archived messages: http://archive.xmldb.org/
----------------------------------------------------------------------

Reply via email to