// PseServer.java import COM.odi.*; import COM.odi.util.OSVector; public class PseServer { private Database oDatabase; private Thread oThread0; // CONSTRUCTORS public PseServer ( String poStringFile ) { init(poStringFile); } // PUBLIC METHODS public void createRoot ( String poString, Object poObject ) { for (boolean t = true; t; ) try { oDatabase.open(Database.openUpdate); Transaction.begin(Transaction.update); oDatabase.createRoot(poString,poObject); t = false; } catch (DatabaseRootAlreadyExistsException x) { t = false; } catch (ObjectStoreException x) { if (!(t = ObjectStore.initialize(oThread0))) throw x; } Transaction.current().commit(); oDatabase.close(); } public void destroyRoot ( String poString, Object poObject ) { for (boolean t = true; t; ) try { oDatabase.open(Database.openUpdate); Transaction.begin(Transaction.update); oDatabase.destroyRoot(poString); t = false; } catch (DatabaseRootNotFoundException x) { t = false; } catch (ObjectStoreException x) { if (!(t = ObjectStore.initialize(oThread0))) throw x; } Transaction.current().commit(); oDatabase.close(); } public Object getRoot ( String poStringRoot ) { for (boolean t = true; t; ) try { oDatabase.open(Database.openUpdate); Transaction.begin(Transaction.update); t = false; } catch (ObjectStoreException x) { if (!(t = ObjectStore.initialize(oThread0))) throw x; } return oDatabase.getRoot(poStringRoot); } public void putRoot ( ) { try { Transaction.current().commit(); oDatabase.close(); } catch (ObjectStoreException x) { x.printStackTrace(); } } // PROTECTED METHODS protected void init ( String poStringFile ) { Database oDB = null; try { oThread0 = Thread.currentThread(); ObjectStore.initialize(null,null); try { oDB = Database.open(poStringFile,Database.openUpdate); } catch (DatabaseNotFoundException x) { oDB = Database.create(poStringFile,Database.ownerWrite); } finally { oDB.close(); oDatabase = oDB; } } catch (Exception x) { x.printStackTrace(); } } }