[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Embedded Ozone...



Hi,

>   Now, I got Ozone up and running. I am wondering if it's
> possible to embedded ozone on my application. I have a
> servlet program that need a embedded database to store
> XML document.

It works, but

- There can only be one database in the whole vm.

    public class Test {
        public static void main(String[] argv) throws Exception {
            LocalDatabase db1 = new LocalDatabase();
            db1.create("/tmp/db1");
            db1.open("/tmp/db1");

            LocalDatabase db2 = new LocalDatabase();
            db2.create("/tmp/db2");
            db2.open("/tmp/db2");
        }
    }

  will not work. Even different databases is different servlets
  will not work.

  Perhaps you can use something like

    public SubDatabase {
        private final String prefix;
        private final LocalDatabase db;

        public SubDatabase(String prefix, LocalDatabase db) {
            this.prefix = prefix;
            this.db = db;
        }

        public OzoneProxy createObject(String className, String name)
        throws Exception { 
            return db.createObject(className, prefix + name);
        }

        .
        .
        .
    }

    public class MasterDatabase {
        private final static LocalDatabase db = new LocalDatabase;

        static {
            db.open("/tmp/db");
        }

        private MasterDatabase() {}

        public subDatabase(String prefix) {
            return new SubDatabase(db, prefix);
        }
    }

  So there would be only one "real" database in the vm and different
  Servlets could use different prefixes for their objects in the db.

- The arguments of the methods of your stored objects have
  to be serializable. Something like
  yourObject.writeTo(servletResponse.getWriter())
  will not work.


 -hannes