You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by ol...@ppi.de on 2003/02/06 10:20:43 UTC

How to use Proxies, was: Re: Null References and Proxies

Hello,

I am still wondering how to use proxies appropriately.
Someone else must have done this before.

> -----Original Message-----
> 
>  I think it is not always necessary to load the referenced object to 
> find whether it is null, since the key of the referenced object is
> known when the first object is loaded. For example, in a particular 
> application a key of zero might mean the referenced object is null. 
> Maybe the reference descriptor could be extended to include 
> an attribute 
> such as null-key="0" to represent this knowledge.

I agree, that would be a nice feature.  

> >In short: Is is intended that a null-reference
> >is wrapped by a proxy?
> >
> >It is unconvenient for several reasons.  It
> >particular, proxies are not as transparent
> >as they could be.

Suppose I want to output a.b.getMsg() 
if and only if a.b != null.

If b is not proxied, I simply write

if (a.b!=null)
	System.out.println(a.b.getMsg())

If b is proxied, however, the above will throw
a NullPointerException.  So, what's the solution?
(An unacceptable solution would be to allow that exception
to be thrown and then catch and ignore it.)

Do I have to test the field-ref field in some way?  

Thank you for your help.

Olli

P.S. I had troubles accessing the list 
the last two days.

-- 
  Dr. Oliver Matz
  ppi Media GmbH
  Deliusstraße 10
  D-24114 Kiel
  phone	+49 (0) 43 1-53 53-422
  fax     	+49 (0) 43 1-53 53-2 22
  email	mailto:oliver.matz@ppi.de
  web	www.ppi.de