org.apache.ojb.broker.core.proxy
Class VirtualProxy

java.lang.Object
  extended byorg.apache.ojb.broker.core.proxy.VirtualProxy
All Implemented Interfaces:
java.io.Serializable

public abstract class VirtualProxy
extends java.lang.Object
implements java.io.Serializable

Proxy base class. can be used to implement lazy materialization techniques.

Version:
$Id: VirtualProxy.java,v 1.1.2.2 2005/01/27 21:18:21 tomdz Exp $
Author:
Thomas Mahler
See Also:
as a sample application., Serialized Form

Constructor Summary
VirtualProxy()
          Creates a new, uninitialized proxy.
VirtualProxy(java.lang.reflect.InvocationHandler handler)
          Create a VirtualProxy that uses the given invocation handler.
VirtualProxy(PBKey key, Identity oid)
          Creates a VirtualProxy for the subject with the given identity.
 
Method Summary
 boolean alreadyMaterialized()
          Determines whether this proxy already has been materialized.
static java.lang.Object createProxy(PBKey key, java.lang.Class proxyClass, Identity realSubjectsIdentity)
          Creates VirtualProxy instances of a given proxy subclass and the real subject's identity.
static IndirectionHandler getIndirectionHandler(VirtualProxy proxy)
          Returns the indirection handler of the given proxy.
 java.lang.Object getRealSubject()
          Returns the proxies real subject.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualProxy

public VirtualProxy()
Creates a new, uninitialized proxy.


VirtualProxy

public VirtualProxy(PBKey key,
                    Identity oid)
Creates a VirtualProxy for the subject with the given identity.

Parameters:
key - The key of the PersistenceBroker
oid - The identity of the subject

VirtualProxy

public VirtualProxy(java.lang.reflect.InvocationHandler handler)
Create a VirtualProxy that uses the given invocation handler. [tomdz] Why here the use of InvocationHandler ?

Parameters:
handler - The indirection handler of the proxy
Method Detail

getIndirectionHandler

public static IndirectionHandler getIndirectionHandler(VirtualProxy proxy)
Returns the indirection handler of the given proxy.

Parameters:
proxy - The proxy
Returns:
The indirection handler

alreadyMaterialized

public boolean alreadyMaterialized()
Determines whether this proxy already has been materialized.

Returns:
true if the real subject already been loaded

createProxy

public static java.lang.Object createProxy(PBKey key,
                                           java.lang.Class proxyClass,
                                           Identity realSubjectsIdentity)
Creates VirtualProxy instances of a given proxy subclass and the real subject's identity.

Parameters:
key - The key of the PersistenceBroker
proxyClass - The Proxy class
realSubjectsIdentity - The identity of the subject
Returns:
An instance of the proxy subclass
Throws:
PersistenceBrokerException - If there is an error creating the proxy object

getRealSubject

public java.lang.Object getRealSubject()
                                throws PersistenceBrokerException
Returns the proxies real subject. The subject will be materialized if necessary.

Returns:
The subject
Throws:
PersistenceBrokerException


(C) 2002 - 2004 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.3, 2005-04-2