Re: How to call createObject from within an OzoneObject?
Arjen van der Meijden <[email protected]>
| Newsgroups | gmane.comp.java.ozone.user |
|---|---|
| Message-ID | <[email protected]> |
On 8-5-2004 21:19, Leo Mekenkamp wrote:
> On Sat, 2004-05-08 at 18:41, Arjen van der Meijden wrote:
>
>>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?
Well, one reason is that I want uniform access to Ozone and as little
knowledge of Ozone anywhere as possible, even in ozone objects.
The second is that I simply didn't know about this.database() I was
looking for a getDatabase and overlooked database() ;)
> (btw: you cannot create an ozone object from
> within an ozone object ctor; the FAQ has more on this)
Ow, I forgot about that.
>> 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'. ;-)
Then again, if you have a guarantee that the init-method will only be
called at application-startup and the destroy-method only after
application-shutdown, why bother about a never-true null-test ?
The only reason it can be null is because openDatabase may return null,
and that results in an Exception (which I left out from this example).
Best regards,
Arjen
-------------------------------------------------------
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