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

Re: Using Dynamic Proxies



On Sun, 01 Apr 2001, Joel Shellman wrote:
> Okay... I think I'm finally fed up enough of trying to explore other db
> possibilities, so I'm going to give Ozone a real try I think.
> 
> There is one thing--I HATE having to preprocess classes (ie. generate
> proxy classes).
> 
> I know I sent an email a long while ago asking why dynamic proxies
> weren't being used instead of the generation method, but I can't
> remember what the response was (suggestion: any chance for searchable
> mail archives?)
There are free mail list servers out there. Which one should we use?

> 
> Anyway, I just checked out the source from CVS, and if anyone wants to
> point me in the right direction (and if no one has any objections), I'll
> try to get some progress towards getting this working.

The only reason to not use dynamic proxies that I'm aware of (and I'm not even
sure with this because I di not check this) is speed. The code to call the
target method is directly compiled into the proxy! Look at the following
example:

   public void print () {
      try {
         Object target = link.fetch (this, Lock.LEVEL_READ);
         if (target != null) {
>>>         ((AutoImpl)target).print();
         }
         else {
            Object[] args = {};
            Object result = link.invoke (this, 14, args, Lock.LEVEL_READ);
         }
       ....

if we are inside the server than the call to the proper target method is
directly done. Absolutely no reflection or something involved. Are dynamic
proxies as fast as this?

Anyway, I think we need both solutions anyway. dynamic proxies for simplified
use with jdk1.3 and generated proxies as (fast?) solution for pre-jdk1.3 users.

Both generated and dynamic proxies have a member they are delegating the method
invocation to. Generated proxies (GP) have the link member which is of type
OzoneInterface. (so they perfectly work outside the server with
ExternalDatabase which is of type OzoneInterface and inside the server with
Database which is of type OzoneInterface too.) Basically all you would have to
do is to write java.lang.reflect.InvocationHandlers that work with
ExternalDatabase and Database. And, change AbstractObjectContainer, which is
the only place where proxies are generated, so that it is able to generate
generated _and_ dynmamic proxies.


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com