Re: How to call createObject from within an OzoneObject?

Leo Mekenkamp <[email protected]>
Newsgroups gmane.comp.java.ozone.user
Message-ID <1084043979.4937.20.camel@jupiter>
On Sat, 2004-05-08 at 18:41, Arjen van der Meijden wrote:
> Hi list,

:-)

> I've been playing around with Ozone, but ran into a small problem:
> When I create an Object via database.createObject and that newly created 
> object wants to create another OzoneObject (say an OzoneMap), that fails 
> in my current code.

What do you mean with 'it fails'? Does it throw an exception?

> Below in the example-code is a marker, and there the code fails, the 
> Ozone-database doesn't know about any OzonePlugIn (actually it is the 
> org.apache.struts.plugin.PlugIn it doesn't know about).
> But even if this code would work, my object would reference the database 
> "it is being created in" via some external, client-side, reference...

Why do you want to go through an extra class (OzoneAccess) from within
an ozone object (FooImpl), when you can simply use this.database() from
within an ozone object? (btw: you cannot create an ozone object from
within an ozone object ctor; the FAQ has more on this)

> So, what is the best way to retrieve some local reference, to the 
> database the object is being created in and use that reference to create 
> member-objects?

As said, this.database().

(...)
>    private static ExternalDatabase db;
(...)
>    public void init()
>    {
>      db = ExternalDatabase.openDatabase(...);
>    }

Initializing a static class variable within a non-static method without
any == null test? No wander we guys from Leiden call you guys from Delft
'fietsenmakers'. ;-)

Mzzl,
Leo
-- 
    .--.      .---------------.----------------------------------------.
   |o_o |     | Leo Mekenkamp | Free, as in 'beer' and as in 'speech': |
   |:_/ |     | +31 641234919 | office software  http://openoffice.org |
  //   \ \    |               | 100% java odbms    http://ozone-db.org |
 (|     | )   | Long Live Tux | e-mail & browser    http://mozilla.org |
/'\_   _/`\   |               | operating system      http://linux.org |
\___)=(___/   `---------------'----------------------------------------'



-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.