From: Andrea F. <and...@cn...> - 2007-12-12 11:03:21
|
Piotr Kaminski wrote: > Hi Andrea, > > Thanks for your interest in the Fluent package. I'm cc'ing this response to the mailing list, so that people can look up the answers in the archives -- I hope you don't mind. > Thanks to you, Piotr :-) >> 1) Which database is isStarted() static method referred to? >> >> startup(File configFile) is referred to databased specified in >> configFile, but isStarted() is unrefereed. >> >> The problem is that if I call isStarted() from the very beginning of my >> code ( without starting it with Database.startup(config.xml) ) it gives >> me obviously a "false" result also if another JVM is running the >> embedded DB. So if an instance of embedded DB is turned on (from another >> JVM), this method doesn't help me and I can not really check form main >> Main with the following code lines: >> >> if(!Database.isStarted()) >> Database.startup(config.xml) >> > > The isStarted() method only checks if a startup() or ensureStarted() call was made successfully in this JVM, and shutdown() wasn't called yet. I've clarified the javadoc (not checked in yet). Actually the only reason I added the method was to enable DatabaseTestCase to do a clean shutdown -- it needs to wipe the database at the end of each test case, and if it tries to wipe when the database wasn't opened successfully then the error from that hides the original error (that occurred when starting the db) in JUnit. > > I agree that it would be useful to be able to tell if the database described by a given config file is currently being accessed by another process. I'll add it to my desired feature list -- I know that eXist checks for a lock when starting up, but usually it just keeps trying to obtain it rather than throwing an exception so this may be a bit tricky to implement. > That should be a useful improvement of isStarted() method (meaning that it checks if an instance of the database is started without regarding JVM instances) > >> 2) The ensureStarted(File configFile) method behavours (and same >> exceptions when there is the same config) to startup(File configFile)... >> Should it work only if there is a different config file DB instance >> running (as written in your javadoc)? Why not with the same config file? >> > > Sorry, I'm not sure I understand the question. My question was (but now I understand the answer, after reading your answer to my first question) about different instances of JVM... Suppose I have the following pieces of codes: public class MyStartupFluent { public static void main(String[] args){ Database.startup(new File("/etc/existdb_config.xml")); Database.login("test","test"); } } public class MyEnsureStartedFluent { public static void main(String[] args){ Database.ensureStarted(new File("/etc/existdb_config.xml")); Database.login("test","test"); } } 1) if I type "java MyFluent" or "java MyEnsureStartedFluent" I start the DB without shutdown (and the DB remains started) 2) typing again "java MyFluent" or "java MyEnsureStartedFluent" I get the same exception (telling that the DB is obviously started) So my question was about the same behaviour of the two methods, but now I understand (from your previous answer) that the difference between the two methods behavours is in the same JVM. In fact the following pieces of code show the different behaviour (in the same JVM): public class MyEnsureStartedFluent { public static void main(String[] args){ Database.ensureStarted(new File("//etc/existdb_config.xml")); Database.login("test","test"); Database.ensureStarted(new File("/etc/existdb_config.xml")); } } public class MyFluent { public static void main(String[] args){ Database.startup(new File("/etc/existdb_config.xml")); Database.login("test","test"); Database.startup(new File("/etc/existdb_config.xml")); } } > startup() is meant to be called precisely once and will fail on extra calls. ensureStartup() works just like startup() on the first call, then on succeeding calls checks that it was called with the same file argument before. If you call it with a different argument, it'll fail. With the isStarted() method there now, I'm no longer convinced ensureStarted() is very useful, and might deprecate it in a future release. > I agree with you. > >> 3) Do you think your interesting APIs will be officially adopted in the >> embedded Exist DB instead of the horrible XMLDB APIs? >> > > I doubt the XMLDB APIs will ever go away, since there's a lot of code out there that uses them. However, once Fluent matures and if it becomes popular, I could certainly see it becoming the preferred API for embedded eXist applications. > I think that your efforts for emdedded eXist (and a serious and reliable JSR 225 X Query API implementation) should be pushed as priority tasks in the roadmap of eXist because XMLDB "bronze age" APIs are not a good business card for a product aiming to became a a feasible approach to store/query XML contents in 2007. > Thanks, and please don't hesitate to follow up with clarifications or further questions! > > -- P. > Thanks to you Piotr, Andrea. |