xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David J. Thomson" <dthom...@eecs.tufts.edu>
Subject Multiple concurrent collections with embedded
Date Wed, 07 May 2003 19:30:12 GMT
Hello,

I'm a little confused about how to handle "sessions" for Xindice. I have a
class called XMLDB, which handles all methods that query the Xindice
database.

I instantiate the class and set the path to the embedded database
dynamically for each session that comes in through the "xindice.home"
property, since each might be using a different database.

The problem is that when I try to get a new collection with
"DatabaseManager.getCollection(String name)", it returns null, but only
when the databases are different.

Will the DatabaseMananger not allow two embedded collections to be loaded
at once when they are phyically distinct? In the code below, it shows that
the xindice.home is set properly and uses a different database when I
print out the property before calling getCollection().

This all seems to work fine for multiple sessions with the same database,
but not when the database is different. Please see the comment inside
the initGlobal() method. Any ideas?

Thanks,

David


// Begin code  for XMLDB.java

Collection sc = null;  // Collection used for each XMLDB object created by
			//each thread

XPathQueryService xp_service = null; // Query service used for ""
Database maindb = null;		// Database used for each session



public XMLDB(Hashtable session) {

System.setProperty( "xindice.home",
System.getProperty("user.dir")+fsep+"roots"+fsep+(String)session.get("sphere_id")+fsep+"DB");
		System.out.println("XMLDB Set as:
"+System.getProperty("user.dir")+fsep+"roots"+fsep+(String)session.get("sphere_id")+fsep+"DB");

System.setProperty("xindice.configuration",System.getProperty("user.dir")+fsep+"system.xml");



	initGlobal();
}


public void initGlobal() {


try {
         String driver =
"org.apache.xindice.client.xmldb.embed.DatabaseImpl";
         Class c = Class.forName(driver);

         maindb = (Database) c.newInstance();
         DatabaseManager.registerDatabase(maindb);



	   sc =
DatabaseManager.getCollection("xmldb:xindice-embed:///db/"+(String)session.get("sphere_id"));
	 try {
	 xp_service =(XPathQueryService)
sc.getService("XPathQueryService", "1.0");

	 } catch (NullPointerException npe) {

		 System.out.println("Why in the world is this null?");
		// This is only null when the database is different, as
		// determined by xindice.home!!!

	 }
      }catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode);
      }
      catch (InstantiationException ie) {
	      System.err.println("ie");
      }
      catch (ClassNotFoundException cnfe) {
	      System.err.println("cnfe");
      }
      catch (IllegalAccessException iae) {
	      System.err.println("iae");
      }





}




Mime
View raw message