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

Re: Ozone port?



On Wed, 06 Oct 1999, Tim Brown wrote:
> I was wondering if there is a way (short of recompiling
> ozone) of setting the ozone port(s)?  I would like to be
> able to run multiple ozone servers at one time.
> 
> I am also wondering if anyone has thought about the access
> problem I am having getting to the same ozone object from
> different RemoteDatabase instances.  I haven't heard
> anything on this yet..

To test the access of one ozone server from two different threads of a client
application I use the following code:

//---------------------------------------------------------------------------
import org.ozoneDB.*;
import org.ozoneDB.test.*;


/** */
class AccessThread extends Thread {
    
    /** */
    public AccessThread() {
        }
    
    /** */
    public void run() {
        try {
            RemoteDatabase db = new RemoteDatabase();
            db.open ("localhost", 3333);
            
            db.reloadClasses();
            System.out.println ("thread(" + hashCode() + "): connected...");
            
            Garage garage = (Garage)db.objectForName ("MG");
            if (garage == null)
               garage = (Garage)db.createObject (GarageImpl.class.getName(), Database.Private, "MG");
           // garage._langeTA (null);
            garage._populate (new Integer(10));
            garage.printAll();

            db.close();
            System.out.println ("deconnected...");
            }
        catch (Exception e) {
            e.printStackTrace();
            }
        }
    }


/** */
public class Client extends Object {
    
    /** */
    public static void main (String[] args) throws Exception {
        try {
            Thread t1 = new AccessThread();
            t1.setPriority (Thread.currentThread().getPriority());
            t1.setName ("t1");
            t1.start();

            Thread t2 = new AccessThread();
            t2.setPriority (Thread.currentThread().getPriority());
            t2.setName ("t2");
            t2.start();

            Thread.currentThread().sleep (1000);
            while (t1.isAlive() || t2.isAlive()) {
                Thread.currentThread().sleep (100);
                }
            }
        catch (Throwable e) {
            e.printStackTrace (System.out);
            }
        }
    }
//---------------------------------------------------------------------------


GarageImpl is a simple container for AutoImpl objects. The _populate(int) 
method of GarageImpl does only create Autos and stores them in the Garage. As
suggested, each thread uses its own connection.

The code works for me without problems. Do you see differences to your code,
Tim?


Falko
-- 
______________________________________________________________________
Falko Braeutigam                         mailto:falko@softwarebuero.de
softwarebuero m&b (SMB)                    http://www.softwarebuero.de